Exemplo n.º 1
0
static gboolean log_button_press_cb(GtkWidget *treeview, GdkEventButton *event, PidginLogViewer *lv)
{
	if (event->type == GDK_BUTTON_PRESS && event->button == 3)
	{
		GtkTreePath *path;
		GtkTreeIter *iter;
		GValue val;
		PurpleLog *log;
		gpointer *data;

		if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), event->x, event->y, &path, NULL, NULL, NULL))
			return FALSE;
		iter = g_new(GtkTreeIter, 1);
		gtk_tree_model_get_iter(GTK_TREE_MODEL(lv->treestore), iter, path);
		val.g_type = 0;
		gtk_tree_model_get_value(GTK_TREE_MODEL(lv->treestore), iter, 1, &val);
		gtk_tree_path_free(path);

		log = g_value_get_pointer(&val);

		if (log == NULL)
		{
			g_free(iter);
			return FALSE;
		}

		data = g_new(gpointer, 4);
		data[0] = lv;
		data[1] = log;
		data[2] = NULL;
		data[3] = iter;

		log_show_popup_menu(treeview, event, data);
		return TRUE;
	}

	return FALSE;
}
Exemplo n.º 2
0
static void
ev_attachment_set_property (GObject      *object,
			    guint         prop_id,
			    const GValue *value,
			    GParamSpec   *param_spec)
{
	EvAttachment *attachment = EV_ATTACHMENT (object);

	switch (prop_id) {
	case PROP_NAME:
		attachment->priv->name = g_value_dup_string (value);
		break;
	case PROP_DESCRIPTION:
		attachment->priv->description = g_value_dup_string (value);
		break;
	case PROP_MTIME:
		attachment->priv->mtime = g_value_get_ulong (value);
		break;
	case PROP_CTIME:
		attachment->priv->ctime = g_value_get_ulong (value);
		break;
	case PROP_SIZE:
		attachment->priv->size = g_value_get_uint (value);
		break;
	case PROP_DATA:
		attachment->priv->data = g_value_get_pointer (value);
		attachment->priv->mime_type = g_content_type_guess (attachment->priv->name,
								    (guchar *) attachment->priv->data,
								    attachment->priv->size,
								    NULL);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
						   prop_id,
						   param_spec);
		break;
	}
}
Exemplo n.º 3
0
static void
peas_extension_set_set_property (GObject      *object,
                                 guint         prop_id,
                                 const GValue *value,
                                 GParamSpec   *pspec)
{
  PeasExtensionSet *set = PEAS_EXTENSION_SET (object);

  switch (prop_id)
    {
    case PROP_ENGINE:
      set->priv->engine = g_value_get_object (value);
      break;
    case PROP_EXTENSION_TYPE:
      set->priv->exten_type = g_value_get_gtype (value);
      break;
    case PROP_CONSTRUCT_PROPERTIES:
      set_construct_properties (set, g_value_get_pointer (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
    }
}
static void
gda_tree_manager_set_property (GObject *object,
                               guint param_id,
                               const GValue *value,
                               GParamSpec *pspec)
{
    GdaTreeManager *manager;

    manager = GDA_TREE_MANAGER (object);
    if (manager->priv) {
        switch (param_id) {
        case PROP_RECURS:
            manager->priv->recursive = g_value_get_boolean (value);
            break;
        case PROP_FUNC:
            manager->priv->update_func = g_value_get_pointer (value);
            break;
        default:
            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
            break;
        }
    }
}
static void
render_contact_method(G_GNUC_UNUSED GtkCellLayout *cell_layout,
                     GtkCellRenderer *cell,
                     GtkTreeModel *model,
                     GtkTreeIter *iter,
                     G_GNUC_UNUSED gpointer data)
{
    GValue value = G_VALUE_INIT;
    gtk_tree_model_get_value(model, iter, 0, &value);
    auto cm = (ContactMethod *)g_value_get_pointer(&value);

    gchar *number = nullptr;
    if (cm && cm->category()) {
        // try to get the number category, eg: "home"
        number = g_strdup_printf("(%s) %s", cm->category()->name().toUtf8().constData(),
                                            cm->uri().toUtf8().constData());
    } else if (cm) {
        number = g_strdup_printf("%s", cm->uri().toUtf8().constData());
    }

    g_object_set(G_OBJECT(cell), "text", number, NULL);
    g_free(number);
}
Exemplo n.º 6
0
static void
moko_history_set_property (GObject      *object,
                           guint         prop_id,
                           const GValue *value,
                           GParamSpec   *pspec)
{
  MokoHistoryPrivate *priv;

  g_return_if_fail (MOKO_IS_HISTORY (object));
  priv = (MOKO_HISTORY (object))->priv;

  switch (prop_id)
  {
    case PROP_JOURNAL:
      priv->journal = (MokoJournal *)g_value_get_pointer (value);
      if (priv->journal)
        moko_history_load_entries (MOKO_HISTORY (object));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
Exemplo n.º 7
0
static void budgie_media_label_set_property(GObject *object,
                                           guint prop_id,
                                           const GValue *value,
                                           GParamSpec *pspec)
{
        BudgieMediaLabel *self;

        self = BUDGIE_MEDIA_LABEL(object);
        switch (prop_id) {
                case PROP_INFO:
                        self->info = g_value_get_pointer((GValue*)value);
                        update_ui(self);
                        break;
                case PROP_PLAYING:
                        self->playing = g_value_get_boolean((GValue*)value);
                        budgie_media_label_set_playing(self, self->playing);
                        break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object,
                                prop_id, pspec);
                        break;
        }
}
Exemplo n.º 8
0
static const void *get_column_value_from_row(GtkTreeView *treeview, int column, int type)
{
    GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
    const void *retval = NULL;
    if (selection)
    {
        GtkTreeIter iter;
        GtkTreeModel *store = gtk_tree_view_get_model(treeview);
        if (gtk_tree_selection_get_selected(selection, &store, &iter) == TRUE)
        {
            GValue value = { 0 };
            gtk_tree_model_get_value(store, &iter, column, &value);
            switch(type){
                case TYPE_STR:
                    retval = g_value_get_string(&value);
                    break;
                case TYPE_POINTER:
                    retval = g_value_get_pointer(&value);
            }
        }
    }
    return retval;
}
Exemplo n.º 9
0
static void
g_win32_output_stream_set_property (GObject         *object,
				    guint            prop_id,
				    const GValue    *value,
				    GParamSpec      *pspec)
{
  GWin32OutputStream *win32_stream;

  win32_stream = G_WIN32_OUTPUT_STREAM (object);

  switch (prop_id)
    {
    case PROP_HANDLE:
      win32_stream->priv->handle = g_value_get_pointer (value);
      break;
    case PROP_CLOSE_HANDLE:
      win32_stream->priv->close_handle = g_value_get_boolean (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
Exemplo n.º 10
0
static void
pseudo_tcp_socket_set_property (GObject *object,
                                  guint property_id,
                                  const GValue *value,
                                  GParamSpec *pspec)
{
  PseudoTcpSocket *self = PSEUDO_TCP_SOCKET (object);

  switch (property_id) {
    case PROP_CONVERSATION:
      self->priv->conv = g_value_get_uint (value);
      break;
    case PROP_CALLBACKS:
      {
        PseudoTcpCallbacks *c = g_value_get_pointer (value);
        self->priv->callbacks = *c;
      }
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
  }
}
Exemplo n.º 11
0
static void
nemo_mime_application_chooser_set_property (GObject *object,
        guint property_id,
        const GValue *value,
        GParamSpec *pspec)
{
    NemoMimeApplicationChooser *chooser = NEMO_MIME_APPLICATION_CHOOSER (object);

    switch (property_id) {
    case PROP_CONTENT_TYPE:
        chooser->details->content_type = g_value_dup_string (value);
        break;
    case PROP_FILES:
        chooser->details->files = g_value_get_pointer (value);
        break;
    case PROP_URI:
        chooser->details->uri = g_value_dup_string (value);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;
    }
}
Exemplo n.º 12
0
static int
edit_plugin_get_index_of_selected_item (PluginEditorDialog *dlg)
{
	int i;
	GnomeUIInfo *curr_item;
	GnomeUIInfo *sysmenus;
	GValue val = {G_TYPE_INVALID};

	if (FALSE == dlg->have_selection) return -1;
	if (! dlg->menus) return -1;

	/* Get selected item */
	gtk_tree_model_get_value (GTK_TREE_MODEL(dlg->treestore),
	                &dlg->curr_selection, PTRCOL, &val);
	curr_item = g_value_get_pointer(&val);

	sysmenus = (GnomeUIInfo *) dlg->menus->data;
	for (i=0; GNOME_APP_UI_ENDOFINFO != sysmenus[i].type; i++)
	{
		if (curr_item == &sysmenus[i]) return i;
	}
	return -1;
}
Exemplo n.º 13
0
void
marshal_BOOLEAN__POINTER (GClosure     *closure,
			  GValue       *return_value,
			  guint         n_param_values,
			  const GValue *param_values,
			  gpointer      invocation_hint,
			  gpointer      marshal_data)
{
  typedef gboolean (*GMarshalFunc_BOOLEAN__POINTER) (gpointer     data1,
                                                     gpointer     arg_1,
                                                     gpointer     data2);
  register GMarshalFunc_BOOLEAN__POINTER callback;
  register GCClosure *cc = (GCClosure*) closure;
  register gpointer data1, data2;
  gboolean v_return;

  g_return_if_fail (return_value != NULL);
  g_return_if_fail (n_param_values == 2);

  if (G_CCLOSURE_SWAP_DATA (closure))
    {
      data1 = closure->data;
      data2 = g_value_peek_pointer (param_values + 0);
    }
  else
    {
      data1 = g_value_peek_pointer (param_values + 0);
      data2 = closure->data;
    }
  callback = (GMarshalFunc_BOOLEAN__POINTER) (marshal_data ? marshal_data : cc->callback);

  v_return = callback (data1,
                       g_value_get_pointer (param_values + 1),
                       data2);

  g_value_set_boolean (return_value, v_return);
}
Exemplo n.º 14
0
static void
purple_smiley_set_property(GObject *object, guint param_id, const GValue *value,
		GParamSpec *spec)
{
	PurpleSmiley *smiley = PURPLE_SMILEY(object);
	switch (param_id) {
		case PROP_SHORTCUT:
			{
				const char *shortcut = g_value_get_string(value);
				purple_smiley_set_shortcut(smiley, shortcut);
			}
			break;
		case PROP_IMGSTORE:
			{
				PurpleStoredImage *img = g_value_get_pointer(value);

				purple_imgstore_unref(smiley->img);
				g_free(smiley->checksum);

				smiley->img = img;
				if (img) {
					smiley->checksum = purple_util_get_image_checksum(
							purple_imgstore_get_data(img),
							purple_imgstore_get_size(img));
					purple_smiley_data_store(img);
				} else {
					smiley->checksum = NULL;
				}

				g_object_notify(object, PROP_IMGSTORE_S);
			}
			break;
		default:
			G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, spec);
			break;
	}
}
Exemplo n.º 15
0
static void
lpf_trip_part_set_property (GObject *object,
                      guint property_id,
                      const GValue *value,
                      GParamSpec *pspec)
{
    LpfTripPart *self = LPF_TRIP_PART (object);
    LpfTripPartPrivate *priv = GET_PRIVATE(self);

    switch (property_id) {
    case LPF_TRIP_PART_PROP_START:
        if (priv->start)
            g_object_unref (priv->start);
        priv->start = g_value_get_object(value);
        break;

    case LPF_TRIP_PART_PROP_END:
        if (priv->end)
            g_object_unref (priv->end);
        priv->end = g_value_get_object(value);
        break;

    case LPF_TRIP_PART_PROP_LINE:
        g_free (priv->line);
        priv->line = g_value_dup_string(value);
        break;

    case LPF_TRIP_PART_PROP_STOPS:
        priv->stops = g_value_get_pointer(value);
        break;

    default:
        /* We don't have any other property... */
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
        break;
    }
}
Exemplo n.º 16
0
static void
coil_expandable_set_property(GObject      *object,
                             guint         property_id,
                             const GValue *value,
                             GParamSpec   *pspec)
{
  CoilExpandable *self = COIL_EXPANDABLE(object);

  switch (property_id)
  {
    case PROP_CONTAINER:
    {
      self->container = g_value_get_object(value);
      break;
    }

    /* TODO(jcon): refactor */
    case PROP_LOCATION:
    {
      if (self->location.filepath)
        g_free(self->location.filepath);

      CoilLocation *loc_ptr;
      loc_ptr = (CoilLocation *)g_value_get_pointer(value);
      if (loc_ptr)
      {
        self->location = *((CoilLocation *)loc_ptr);
        self->location.filepath = g_strdup(loc_ptr->filepath);
      }
      break;
    }

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
      break;
  }
}
Exemplo n.º 17
0
static void
gupnp_service_info_set_property (GObject      *object,
                                 guint         property_id,
                                 const GValue *value,
                                 GParamSpec   *pspec)
{
        GUPnPServiceInfo *info;

        info = GUPNP_SERVICE_INFO (object);

        switch (property_id) {
        case PROP_CONTEXT:
                info->priv->context = g_object_ref (g_value_get_object (value));
                break;
        case PROP_LOCATION:
                info->priv->location = g_value_dup_string (value);
                break;
        case PROP_UDN:
                info->priv->udn = g_value_dup_string (value);
                break;
        case PROP_SERVICE_TYPE:
                info->priv->service_type = g_value_dup_string (value);
                break;
        case PROP_URL_BASE:
                info->priv->url_base = g_value_dup_boxed (value);
                break;
        case PROP_DOCUMENT:
                info->priv->doc = g_value_dup_object (value);
                break;
        case PROP_ELEMENT:
                info->priv->element = g_value_get_pointer (value);
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                break;
        }
}
Exemplo n.º 18
0
static void
gupnp_didl_lite_create_class_set_property (GObject      *object,
                                            guint         property_id,
                                            const GValue *value,
                                            GParamSpec   *pspec)
{
        GUPnPDIDLLiteCreateClass *create_class;

        create_class = GUPNP_DIDL_LITE_CREATE_CLASS (object);

        switch (property_id) {
        case PROP_XML_NODE:
                create_class->priv->xml_node = g_value_get_pointer (value);
                break;
        case PROP_XML_DOC:
                create_class->priv->xml_doc = g_value_dup_object (value);
                break;
        case PROP_CONTENT:
                gupnp_didl_lite_create_class_set_content
                                                 (create_class,
                                                  g_value_get_string (value));
                break;
        case PROP_INCLUDE_DERIVED:
                gupnp_didl_lite_create_class_set_include_derived
                                                 (create_class,
                                                  g_value_get_boolean (value));
                break;
        case PROP_FRIENDLY_NAME:
                gupnp_didl_lite_create_class_set_friendly_name
                                                 (create_class,
                                                  g_value_get_string (value));
                break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
                break;
        }
}
Exemplo n.º 19
0
static void
seahorse_gpgme_uid_set_property (GObject *object, guint prop_id, const GValue *value, 
                               GParamSpec *pspec)
{
	SeahorseGpgmeUid *self = SEAHORSE_GPGME_UID (object);
	gpgme_key_t pubkey;
	
	switch (prop_id) {
	case PROP_PUBKEY:
		pubkey = g_value_get_boxed (value);
		g_return_if_fail (pubkey);

		if (pubkey != self->pv->pubkey) {
			
			if (self->pv->pubkey) {
				/* Should always be set to the same actual key */
				g_return_if_fail (compare_pubkeys (pubkey, self->pv->pubkey));
				gpgme_key_unref (self->pv->pubkey);
			}
			
			self->pv->pubkey = g_value_get_boxed (value);
			if (self->pv->pubkey)
				gpgme_key_ref (self->pv->pubkey);
			
			/* This is expected to be set shortly along with pubkey */
			self->pv->userid = NULL;
		}
		break;
	case PROP_ACTUAL_INDEX:
		seahorse_gpgme_uid_set_actual_index (self, g_value_get_uint (value));
		break;
	case PROP_USERID:
		seahorse_gpgme_uid_set_userid (self, g_value_get_pointer (value));
		break;
	}
}
Exemplo n.º 20
0
/* DND */
static void
drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx,
  GtkSelectionData *data, guint info, guint time,
  gpointer user_data)
{
  GtkListStore *ls = (GtkListStore *) user_data;
        
  if (ls == NULL) return;
  
  if (data->target == gdk_atom_intern ("STRING", FALSE)) {
    GtkTreeRowReference *ref;
    GtkTreePath *source_row;
    GtkTreeIter iter;
    GString *s;
    struct widget *w;
    GValue val = {0};

    ref = g_object_get_data (G_OBJECT(ctx), "gtk-tree-view-source-row");
    source_row = gtk_tree_row_reference_get_path (ref);

    if (source_row == NULL) return;

    gtk_tree_model_get_iter(GTK_TREE_MODEL(ls), &iter, source_row);
    gtk_tree_model_get_value(GTK_TREE_MODEL(ls), &iter,
      1, &val);

    w = g_value_get_pointer (&val);
    s = g_string_new ("");
    g_string_printf (s, "[%s]", w->alias);
    gtk_selection_data_set (data, gdk_atom_intern ("STRING", FALSE),
      8, (guchar *)s->str, strlen(s->str)+1);

    g_string_free (s, TRUE);
    gtk_tree_path_free (source_row);
  } 
}
Exemplo n.º 21
0
static void component_response_cb(GtkWidget *d, int response, 
  GtkTreeSelection *sel)
{
  GtkTreeModel *model;
  GtkTreeIter iter;
  GValue val;
  struct component *c;

  switch (response) {
    case AP_RESPONSE_CHOOSE:
      gtk_tree_selection_get_selected (sel, &model, &iter);
      val.g_type = 0;
      gtk_tree_model_get_value (model, &iter, 1, &val);
      c = g_value_get_pointer(&val);
      add_component (c);
    case GTK_RESPONSE_CLOSE:
    case GTK_RESPONSE_CANCEL:
    case GTK_RESPONSE_DELETE_EVENT:
      gtk_widget_destroy(d);
      component_dialog = NULL;
      choose_button = NULL;
      break;
  }
}
Exemplo n.º 22
0
static gboolean
visibility_filter_func(GtkTreeModel *model,
		       GtkTreeIter *iter,
		       gpointer data)
{
	GValue val = {0, };
	CookieInfo *info;
	PdmActionInfo *action = (PdmActionInfo *)data;

	if (action->filter_string == NULL) return TRUE;

	gtk_tree_model_get_value(model, iter, action->data_col, &val);

	/* Bit of a sneaky hack. Cookies/passwords/permissions have
	 * different structs, but all have domain/hostname as the first
	 * field. So we can get away with this fudge
	 */
	info = (CookieInfo *)g_value_get_pointer(&val);

	if (g_strrstr(info->domain, action->filter_string) != NULL)
		return TRUE;
	else
		return FALSE;
}
Exemplo n.º 23
0
static GtkTreeIter *
history_dialog_find_site_iter (HistoryDialog *dialog,
			       GtkTreeIter *host_iter,
			       HistoryItem *item)
{
	GtkTreeIter iter;
	
	gtk_tree_model_iter_children (dialog->priv->model,
				      &iter,
				      host_iter);

	do
	{
		GValue val = { 0, }; 
		HistoryItem *i;
		gtk_tree_model_get_value (dialog->priv->model, 
					  &iter, 5, &val);
		i = (HistoryItem *) g_value_get_pointer (&val);
		if (i == item) return gtk_tree_iter_copy (&iter); 
	}
	while (gtk_tree_model_iter_next (dialog->priv->model, &iter));
	
	return NULL;
}
Exemplo n.º 24
0
/* property mutator */
void
thrift_memory_buffer_set_property (GObject *object, guint property_id,
                                   const GValue *value, GParamSpec *pspec)
{
  ThriftMemoryBuffer *t = THRIFT_MEMORY_BUFFER (object);

  THRIFT_UNUSED_VAR (pspec);

  switch (property_id)
  {
    case PROP_THRIFT_MEMORY_BUFFER_BUFFER_SIZE:
      t->buf_size = g_value_get_uint (value);
      break;
    case PROP_THRIFT_MEMORY_BUFFER_BUFFER:
      t->buf = (GByteArray*) g_value_get_pointer (value);
      break;
    case PROP_THRIFT_MEMORY_BUFFER_OWNER:
      t->owner = g_value_get_boolean (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
  }
}
static void
panel_ditem_editor_set_property (GObject       *object,
				 guint	       prop_id,
				 const GValue *value,
				 GParamSpec   *pspec)
{
	PanelDItemEditor *dialog;

	g_return_if_fail (PANEL_IS_DITEM_EDITOR (object));

	dialog = PANEL_DITEM_EDITOR (object);

	switch (prop_id) {
	case PROP_KEYFILE:
		panel_ditem_editor_set_key_file (dialog, g_value_get_pointer (value));
		break;
	case PROP_URI:
		panel_ditem_editor_set_uri (dialog, g_value_get_string (value));
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
Exemplo n.º 26
0
static void
gst_skor_sink_set_property (GObject * object, guint prop_id,
    const GValue * value, GParamSpec * pspec)
{
  GstSkorSink *filter = GST_SKORSINK (object);

  switch (prop_id) {
    case PROP_CACHE:
      filter->cache = g_value_get_boolean (value);
      break;
    case PROP_MESSAGE:
      filter->message = g_value_get_boolean (value);
      break;
    case PROP_ATTACH_FRAME:
      filter->attach_frame = g_value_get_boolean (value);
      break;
    case PROP_DATA_CONSUMER:
      filter->data_consumer = g_value_get_pointer (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
  }
}
Exemplo n.º 27
0
static HaskellObj
#ifdef GHC_RTS_USES_CAPABILITY
gtk2hs_value_as_haskellobj(Capability *cap, const GValue *value) {
#else
gtk2hs_value_as_haskellobj(const GValue *value) {
#endif
    switch (G_TYPE_FUNDAMENTAL(G_VALUE_TYPE(value))) {
    case G_TYPE_INTERFACE:
        if (g_type_is_a(G_VALUE_TYPE(value), G_TYPE_OBJECT))
            return rts_mkPtr(CAP g_value_get_object(value));
        else
            break;
    case G_TYPE_CHAR:
        return rts_mkChar(CAP g_value_get_schar(value));
    case G_TYPE_UCHAR:
        return rts_mkChar(CAP g_value_get_uchar(value));
    case G_TYPE_BOOLEAN:
        return rts_mkBool(CAP g_value_get_boolean(value));
    case G_TYPE_INT:
        return rts_mkInt(CAP g_value_get_int(value));
    case G_TYPE_UINT:
        return rts_mkWord(CAP g_value_get_uint(value));
    case G_TYPE_LONG:
        return rts_mkInt(CAP g_value_get_long(value));
    case G_TYPE_ULONG:
        return rts_mkWord(CAP g_value_get_ulong(value));
    /*    case G_TYPE_INT64:
            return rts_mkInt64(CAP g_value_get_int64(value));
        case G_TYPE_UINT64:
            return rts_mkWord64(CAP g_value_get_uint64(value));   */
    case G_TYPE_ENUM:
        return rts_mkInt(CAP g_value_get_enum(value));
    case G_TYPE_FLAGS:
        return rts_mkWord(CAP g_value_get_enum(value));
    case G_TYPE_FLOAT:
        return rts_mkFloat(CAP g_value_get_float(value));
    case G_TYPE_DOUBLE:
        return rts_mkDouble(CAP g_value_get_double(value));
    case G_TYPE_STRING:
        return rts_mkPtr(CAP (char *)g_value_get_string(value)); /* CHECKME: is the string freed? */
    case G_TYPE_POINTER:
        return rts_mkPtr(CAP g_value_get_pointer(value));
    case G_TYPE_BOXED:
        return rts_mkPtr(CAP g_value_get_boxed(value));
    case G_TYPE_PARAM:
        return rts_mkPtr(CAP g_value_get_param(value));
    case G_TYPE_OBJECT:
        return rts_mkPtr(CAP g_value_get_object(value));
    }
    g_error("gtk2hs_value_as_haskellobj: unable to handle GValue with type %s\n"
            "please report this as a bug to [email protected]",
            g_type_name(G_VALUE_TYPE(value)));
}

void
gtk2hs_value_from_haskellobj(GValue *value, HaskellObj obj) {

    switch (G_TYPE_FUNDAMENTAL(G_VALUE_TYPE(value))) {
    case G_TYPE_INVALID:
    case G_TYPE_NONE:
        return;
    case G_TYPE_INTERFACE:
        /* we only handle interface types that have a GObject prereq */
        if (g_type_is_a(G_VALUE_TYPE(value), G_TYPE_OBJECT)) {
            g_value_set_object(value, rts_getPtr(obj));
        } else {
            break;
        }
        return;
    case G_TYPE_CHAR:
        g_value_set_schar(value, rts_getChar(obj));
        return;
    case G_TYPE_UCHAR:
        g_value_set_schar(value, rts_getChar(obj));
        return;
    case G_TYPE_BOOLEAN:
        g_value_set_boolean(value, rts_getBool(obj));
        return;
    case G_TYPE_INT:
        g_value_set_int(value, rts_getInt(obj));
        return;
    case G_TYPE_UINT:
        g_value_set_uint(value, rts_getWord(obj));
        return;
    case G_TYPE_LONG:
        g_value_set_long(value, rts_getInt(obj));
        return;
    case G_TYPE_ULONG:
        g_value_set_ulong(value, rts_getWord(obj));
        return;
    /*    case G_TYPE_INT64:
            g_value_set_int64(value, rts_getInt64(obj));
            return;
        case G_TYPE_UINT64:
            g_value_set_uint64(value, rts_getWord64(obj));
            return;                                         */
    case G_TYPE_ENUM:
        g_value_set_enum(value, rts_getInt(obj));
        return;
    case G_TYPE_FLAGS:
        g_value_set_flags(value, rts_getInt(obj));
        return;
    case G_TYPE_FLOAT:
        g_value_set_float(value, rts_getFloat(obj));
        return;
    case G_TYPE_DOUBLE:
        g_value_set_double(value, rts_getDouble(obj));
        return;
    case G_TYPE_STRING:
        g_value_set_string(value, rts_getPtr(obj));
        return;
    case G_TYPE_POINTER:
        g_value_set_pointer(value, rts_getPtr(obj));
        return;
    /*    case G_TYPE_BOXED: {
            g_value_set_boxed(value, obj);
            break;
        }
        case G_TYPE_PARAM:
            g_value_set_param(value, (obj));
            break;                                          */
    case G_TYPE_OBJECT:
        g_value_set_object(value, rts_getPtr(obj));
        return;
    }
    g_error("gtk2hs_value_from_haskellobj: unable to handle GValue with type %s\n"
            "please report this as a bug to [email protected]",
            g_type_name(G_VALUE_TYPE(value)));
}
Exemplo n.º 28
0
void
ags_file_set_property(GObject *gobject,
		      guint prop_id,
		      const GValue *value,
		      GParamSpec *param_spec)
{
  AgsFile *file;

  pthread_mutex_t *file_mutex;

  file = AGS_FILE(gobject);

  /* get file mutex */
  pthread_mutex_lock(ags_file_get_class_mutex());
  
  file_mutex = file->obj_mutex;
  
  pthread_mutex_unlock(ags_file_get_class_mutex());

  switch(prop_id){
  case PROP_FILENAME:
    {
      gchar *filename;

      filename = g_value_get_string(value);

      pthread_mutex_lock(file_mutex);

      if(file->filename == filename){
	pthread_mutex_unlock(file_mutex);
	
	return;
      }

      if(file->filename != NULL){
	g_free(file->filename);
      }
      
      file->filename = g_strdup(filename);

      pthread_mutex_unlock(file_mutex);
    }
    break;
  case PROP_ENCODING:
    {
      gchar *encoding;

      encoding = g_value_get_string(value);

      pthread_mutex_lock(file_mutex);

      file->encoding = encoding;

      pthread_mutex_unlock(file_mutex);
    }
    break;
  case PROP_AUDIO_FORMAT:
    {
      gchar *audio_format;

      audio_format = g_value_get_string(value);

      pthread_mutex_lock(file_mutex);

      file->audio_format = audio_format;

      pthread_mutex_unlock(file_mutex);
    }
    break;
  case PROP_AUDIO_ENCODING:
    {
      gchar *audio_encoding;

      audio_encoding = g_value_get_string(value);

      pthread_mutex_lock(file_mutex);

      file->audio_encoding = audio_encoding;

      pthread_mutex_unlock(file_mutex);
    }
    break;
  case PROP_XML_DOC:
    {
      xmlDoc *doc;

      doc = (xmlDoc *) g_value_get_pointer(value);
      
      pthread_mutex_lock(file_mutex);

      file->doc = doc;

      pthread_mutex_unlock(file_mutex);
    }
    break;
  case PROP_APPLICATION_CONTEXT:
    {
      GObject *application_context;

      application_context = g_value_get_object(value);

      pthread_mutex_lock(file_mutex);

      if(file->application_context == application_context){
	pthread_mutex_unlock(file_mutex);

	return;
      }

      if(file->application_context != NULL){
	g_object_unref(file->application_context);
      }

      if(application_context != NULL){
	g_object_ref(application_context);
      }

      file->application_context = application_context;

      pthread_mutex_unlock(file_mutex);
    }
    break;
  default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, param_spec);
    break;
  }
}
Exemplo n.º 29
0
void
_gtk_tree_data_list_value_to_node (GtkTreeDataList *list,
				   GValue          *value)
{
  switch (get_fundamental_type (G_VALUE_TYPE (value)))
    {
    case G_TYPE_BOOLEAN:
      list->data.v_int = g_value_get_boolean (value);
      break;
    case G_TYPE_CHAR:
      list->data.v_char = g_value_get_schar (value);
      break;
    case G_TYPE_UCHAR:
      list->data.v_uchar = g_value_get_uchar (value);
      break;
    case G_TYPE_INT:
      list->data.v_int = g_value_get_int (value);
      break;
    case G_TYPE_UINT:
      list->data.v_uint = g_value_get_uint (value);
      break;
    case G_TYPE_LONG:
      list->data.v_long = g_value_get_long (value);
      break;
    case G_TYPE_ULONG:
      list->data.v_ulong = g_value_get_ulong (value);
      break;
    case G_TYPE_INT64:
      list->data.v_int64 = g_value_get_int64 (value);
      break;
    case G_TYPE_UINT64:
      list->data.v_uint64 = g_value_get_uint64 (value);
      break;
    case G_TYPE_ENUM:
      list->data.v_int = g_value_get_enum (value);
      break;
    case G_TYPE_FLAGS:
      list->data.v_uint = g_value_get_flags (value);
      break;
    case G_TYPE_POINTER:
      list->data.v_pointer = g_value_get_pointer (value);
      break;
    case G_TYPE_FLOAT:
      list->data.v_float = g_value_get_float (value);
      break;
    case G_TYPE_DOUBLE:
      list->data.v_double = g_value_get_double (value);
      break;
    case G_TYPE_STRING:
      g_free (list->data.v_pointer);
      list->data.v_pointer = g_value_dup_string (value);
      break;
    case G_TYPE_OBJECT:
      if (list->data.v_pointer)
	g_object_unref (list->data.v_pointer);
      list->data.v_pointer = g_value_dup_object (value);
      break;
    case G_TYPE_BOXED:
      if (list->data.v_pointer)
	g_boxed_free (G_VALUE_TYPE (value), list->data.v_pointer);
      list->data.v_pointer = g_value_dup_boxed (value);
      break;
    case G_TYPE_VARIANT:
      if (list->data.v_pointer)
	g_variant_unref (list->data.v_pointer);
      list->data.v_pointer = g_value_dup_variant (value);
      break;
    default:
      g_warning ("%s: Unsupported type (%s) stored.", G_STRLOC, g_type_name (G_VALUE_TYPE (value)));
      break;
    }
}
Exemplo n.º 30
0
static void
gst_pocketsphinx_set_property(GObject * object, guint prop_id,
                              const GValue * value, GParamSpec * pspec)
{
    GstPocketSphinx *ps = GST_POCKETSPHINX(object);

    switch (prop_id) {
    
    case PROP_CONFIGURED:
        ps_reinit(ps->ps, ps->config);
        break;
    case PROP_HMM_DIR:
        gst_pocketsphinx_set_string(ps, "-hmm", value);
        break;
    case PROP_LM_FILE:
        /* FSG and LM are mutually exclusive. */
        gst_pocketsphinx_set_string(ps, "-fsg", NULL);
        gst_pocketsphinx_set_string(ps, "-lmctl", NULL);
        gst_pocketsphinx_set_string(ps, "-lm", value);
        break;
    case PROP_LMCTL_FILE:
        /* FSG and LM are mutually exclusive. */
        gst_pocketsphinx_set_string(ps, "-fsg", NULL);
        gst_pocketsphinx_set_string(ps, "-lmctl", value);
        gst_pocketsphinx_set_string(ps, "-lm", NULL);
        break;
    case PROP_LM_NAME:
        gst_pocketsphinx_set_string(ps, "-fsg", NULL);
        gst_pocketsphinx_set_string(ps, "-lm", NULL);
        gst_pocketsphinx_set_string(ps, "-lmname", value);

        /**
         * Chances are that lmctl is already loaded and all
         * corresponding searches are configured, so we simply
         * try to set the search
         */

        if (value != NULL) {
    	    ps_set_search(ps->ps, g_value_get_string(value));
        }
        break;
    case PROP_DICT_FILE:
        gst_pocketsphinx_set_string(ps, "-dict", value);
        break;
    case PROP_MLLR_FILE:
        gst_pocketsphinx_set_string(ps, "-mllr", value);
        break;
    case PROP_FSG_MODEL:
        {
            fsg_model_t *fsg = g_value_get_pointer(value);
            const char *name = fsg_model_name(fsg);
            ps_set_fsg(ps->ps, name, fsg);
            ps_set_search(ps->ps, name);
        }
        break;
    case PROP_FSG_FILE:
        /* FSG and LM are mutually exclusive */
        gst_pocketsphinx_set_string(ps, "-lm", NULL);
        gst_pocketsphinx_set_string(ps, "-fsg", value);
        break;
    case PROP_FWDFLAT:
        gst_pocketsphinx_set_boolean(ps, "-fwdflat", value);
        break;
    case PROP_BESTPATH:
        gst_pocketsphinx_set_boolean(ps, "-bestpath", value);
        break;
    case PROP_LATDIR:
        if (ps->latdir)
            g_free(ps->latdir);
        ps->latdir = g_strdup(g_value_get_string(value));
        break;
    case PROP_MAXHMMPF:
        gst_pocketsphinx_set_int(ps, "-maxhmmpf", value);
        break;
    case PROP_MAXWPF:
        gst_pocketsphinx_set_int(ps, "-maxwpf", value);
        break;
    case PROP_BEAM:
        gst_pocketsphinx_set_double(ps, "-beam", value);
        break;
    case PROP_PBEAM:
        gst_pocketsphinx_set_double(ps, "-pbeam", value);
        break;
    case PROP_WBEAM:
        gst_pocketsphinx_set_double(ps, "-wbeam", value);
        break;
    case PROP_DSRATIO:
        gst_pocketsphinx_set_int(ps, "-ds", value);
        break;
    default:
        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
        return;
    }
}