示例#1
0
/**
 * gst_plugin_feature_list_copy:
 * @list: (transfer none) (element-type Gst.PluginFeature): list
 *     of #GstPluginFeature
 *
 * Copies the list of features. Caller should call @gst_plugin_feature_list_free
 * when done with the list.
 *
 * Returns: (transfer full) (element-type Gst.PluginFeature): a copy of @list,
 *     with each feature's reference count incremented.
 */
GList *
gst_plugin_feature_list_copy (GList * list)
{
  GList *new_list = NULL;

  if (G_LIKELY (list)) {
    GList *last;

    new_list = g_list_alloc ();
    new_list->data = gst_object_ref (list->data);
    new_list->prev = NULL;
    last = new_list;
    list = list->next;
    while (list) {
      last->next = g_list_alloc ();
      last->next->prev = last;
      last = last->next;
      last->data = gst_object_ref (list->data);
      list = list->next;
    }
    last->next = NULL;
  }

  return new_list;
}
示例#2
0
/**
 * g_list_insert_before:
 * @list: a pointer to a #GList, this must point to the top of the list
 * @sibling: the list element before which the new element
 *     is inserted or %NULL to insert at the end of the list
 * @data: the data for the new element
 *
 * Inserts a new element into the list before the given position.
 *
 * Returns: the (possibly changed) start of the #GList
 */
GList *
g_list_insert_before (GList    *list,
                      GList    *sibling,
                      gpointer  data)
{
  if (!list)
    {
      list = g_list_alloc ();
      list->data = data;
      g_return_val_if_fail (sibling == NULL, list);
      return list;
    }
  else if (sibling)
    {
      GList *node;

      node = _g_list_alloc ();
#ifdef GSTREAMER_LITE
      if (node == NULL) {
        return NULL;
      }
#endif // GSTREAMER_LITE
      node->data = data;
      node->prev = sibling->prev;
      node->next = sibling;
      sibling->prev = node;
      if (node->prev)
        {
          node->prev->next = node;
          return list;
        }
      else
        {
          g_return_val_if_fail (sibling == list, node);
          return node;
        }
    }
  else
    {
      GList *last;

      last = list;
      while (last->next)
        last = last->next;

      last->next = _g_list_alloc ();
#ifdef GSTREAMER_LITE
      if (last->next == NULL) {
        return NULL;
      }
#endif // GSTREAMER_LITE
      last->next->data = data;
      last->next->prev = last;
      last->next->next = NULL;

      return list;
    }
}
示例#3
0
void add_tid_to_bad_list(pid_t pid) {
	if (!bad_tid_list) {
		bad_tid_list = g_list_alloc();
	}
	pid_t *ptr = malloc(sizeof(pid_t));
	if (ptr) {
		*ptr = pid;
		bad_tid_list = g_list_append(bad_tid_list, ptr);
	}
}
示例#4
0
int wxComboBox::DoInsert(const wxString &item, unsigned int pos)
{
    wxCHECK_MSG( !(GetWindowStyle() & wxCB_SORT), -1,
                    wxT("can't insert into sorted list"));

    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );
    wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index") );

    unsigned int count = GetCount();

    if (pos == count)
        return Append(item);

#ifdef __WXGTK24__
    if (!gtk_check_version(2,4,0))
    {
        GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
        gtk_combo_box_insert_text( combobox, pos, wxGTK_CONV( item ) );
    }
    else
#endif
    {
        DisableEvents();

        GtkWidget *list = GTK_COMBO(m_widget)->list;
        GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( item ) );

        GList *gitem_list = g_list_alloc ();
        gitem_list->data = list_item;
        gtk_list_insert_items( GTK_LIST (list), gitem_list, pos );

        if (GTK_WIDGET_REALIZED(m_widget))
        {
            gtk_widget_realize( list_item );
            gtk_widget_realize( GTK_BIN(list_item)->child );

            ApplyWidgetStyle();
        }

        gtk_widget_show( list_item );

        EnableEvents();
    }

    count = GetCount();

    if ( m_clientDataList.GetCount() < count )
        m_clientDataList.Insert( pos, (wxObject*) NULL );
    if ( m_clientObjectList.GetCount() < count )
        m_clientObjectList.Insert( pos, (wxObject*) NULL );

    InvalidateBestSize();

    return pos;
}
示例#5
0
文件: rpm.c 项目: wlindauer/abrt
void rpm_init()
{
#ifdef HAVE_LIBRPM
    if (rpmReadConfigFiles(NULL, NULL) != 0)
        error_msg("Can't read RPM rc files");
#endif

    list_free_with_free(list_fingerprints); /* paranoia */
    /* Huh? Why do we start the list with an element with NULL string? */
    list_fingerprints = g_list_alloc();
}
示例#6
0
static inline GList*
new_node (GList *prev, gpointer data, GList *next)
{
    GList *node = g_list_alloc ();
    node->data = data;
    node->prev = prev;
    node->next = next;
    if (prev)
        prev->next = node;
    if (next)
        next->prev = node;
    return node;
}
示例#7
0
int
main (int   argc,
      char* argv[])
{
  FILE *file;
  gchar buf[1024];
  GList *list;
  GList *result;
  GList *tmp;
  GCompletion *cmp;
  gint i;
  gchar *longp = NULL;
  
  if (argc < 3)
    {
      g_warning ("Usage: %s filename prefix1 [prefix2 ...]\n", argv[0]);
      return 1;
    }
  
  file = fopen (argv[1], "r");
  if (!file)
    {
      g_warning ("Cannot open %s\n", argv[1]);
      return 1;
    }
  
  cmp = g_completion_new (NULL);
  list = g_list_alloc ();
  while (fgets (buf, 1024, file))
    {
      list->data = g_strdup (buf);
      g_completion_add_items (cmp, list);
    }
  fclose (file);
  
  for (i = 2; i < argc; ++i)
    {
      printf ("COMPLETING: %s\n", argv[i]);
      result = g_completion_complete (cmp, argv[i], &longp);
      g_list_foreach (result, (GFunc) printf, NULL);
      printf ("LONG MATCH: %s\n", longp);
      g_free (longp);
      longp = NULL;
    }
  
  g_list_foreach (cmp->items, (GFunc) g_free, NULL);
  g_completion_free (cmp);
  g_list_free (list);
  
  return 0;
}
示例#8
0
/**
 * ags_output_map_audio_signal:
 * @output: an #AgsOutput
 * @recall_id: the assigned #AgsRecallID
 *
 * Maps audio signal and assigning it to recall id.
 *
 * Returns: a new #GList containing #AgsAudioSignal
 *
 * Since: 0.4
 */
GList*
ags_output_map_audio_signal(AgsOutput *output, AgsRecallID *recall_id)
{
  AgsDevout *devout;
  AgsAudioSignal *audio_signal;
  GList *list_destination;

  if(output != NULL){
    list_destination = g_list_alloc();
    goto ags_copy_pattern_map_destination0;
  }else
    return(NULL);

  devout = AGS_DEVOUT(AGS_AUDIO(AGS_CHANNEL(output)->audio)->devout);
  
  while(output != NULL){
    list_destination->next = g_list_alloc();
    list_destination->next->prev = list_destination;
    list_destination = list_destination->next;
  ags_copy_pattern_map_destination0:
    g_message("ags_output_map_audio_signal\n\0");

    audio_signal = ags_audio_signal_new((GObject *) devout,
					(GObject *) output->channel.first_recycling,
					(GObject *) recall_id);
    ags_connectable_connect(AGS_CONNECTABLE(audio_signal));

    ags_recycling_add_audio_signal(output->channel.first_recycling,
				   audio_signal);
    audio_signal->stream_current = audio_signal->stream_beginning;
    list_destination->data = (gpointer) audio_signal;

    output = (AgsOutput *) output->channel.next_pad;
  }
  
  return(list_destination);
}
示例#9
0
文件: util.c 项目: richwolski/bluesky
GList *bluesky_list_append(GList *head, BlueSkyInode *inode)
{
    if (head->next == NULL)
        return bluesky_list_prepend(head, inode);

    g_assert(head->prev != NULL && head->prev->next == NULL);

    GList *link = g_list_alloc();
    link->data = inode;
    link->next = NULL;
    link->prev = head->prev;
    head->prev->next = link;
    head->prev = link;
    return link;
}
示例#10
0
//__________________________________________________________________
void        _HYPlatformPullDown::_AddMenuItem   (_String& newItem, long index)
{
    if (theMenu) {
        GList * singleItem   = g_list_alloc();
        singleItem->prev = singleItem->next = nil;
        if (newItem.Equal(&menuSeparator)) {
            GtkWidget * itemContents = gtk_separator_menu_item_new ();
            gtk_widget_show (itemContents);
            singleItem->data = gtk_list_item_new();
            gtk_container_add((GtkContainer*)singleItem->data,itemContents);
            gtk_combo_set_item_string (GTK_COMBO (theMenu), GTK_ITEM (singleItem->data), "");
            gtk_widget_set_sensitive((GtkWidget*)singleItem->data,false);
            widgetList.InsertElement ((BaseRef)itemContents,2*index,false,false);
        } else {
            _String inItem = newItem;
            if (newItem.beginswith ("(")) {
                inItem.Trim (1,-1);
            }

            GtkWidget * itemContents = gtk_menu_item_new_with_label (inItem.sData);
            gtk_widget_show (itemContents);
            singleItem->data = gtk_list_item_new();
            gtk_container_add((GtkContainer*)singleItem->data,itemContents);
            gtk_combo_set_item_string (GTK_COMBO (theMenu), GTK_ITEM (singleItem->data), inItem.sData);
            gtk_widget_set_sensitive((GtkWidget*)singleItem->data,inItem.sLength == newItem.sLength);
            widgetList.InsertElement ((BaseRef)itemContents,2*index,false,false);
        }
        widgetList.InsertElement ((BaseRef)singleItem->data,2*index,false,false);
        GdkColor convColor = HYColorToGDKColor(_hyGTKMenuBackground);
        gtk_widget_modify_bg ((GtkWidget*)singleItem->data, GTK_STATE_INSENSITIVE, 
        	&convColor);
        gtk_widget_show ((GtkWidget*)singleItem->data);
        if (index<0) {
            gtk_list_append_items (GTK_LIST (GTK_COMBO (theMenu)->list), singleItem);
        } else {
            gtk_list_insert_items (GTK_LIST (GTK_COMBO (theMenu)->list), singleItem, index);
        }

        /*printf ("\nAdding menu item %s at %d\n", newItem.sData, index);
        for (long k = 0; k<widgetList.lLength; k++)
            printf ("%d %s\n", k, GTK_OBJECT_TYPE_NAME (GTK_WIDGET (widgetList(k))));*/
    }

    if (((_HYPullDown*)this)->MenuItemCount()==1||selection==index) {
        cbSelection = -1;
        _RefreshComboBox();
    }
}
示例#11
0
GList *
tracker_priority_queue_add (TrackerPriorityQueue *queue,
                            gpointer              data,
                            gint                  priority)
{
	GList *node;

	g_return_val_if_fail (queue != NULL, NULL);
	g_return_val_if_fail (data != NULL, NULL);

	node = g_list_alloc ();
	node->data = data;
	insert_node (queue, priority, node);

	return node;
}
示例#12
0
void
ags_drum_input_line_set_channel(AgsLine *line, AgsChannel *channel)
{
  AgsDrumInputLine *drum_input_line;

  AGS_LINE_CLASS(ags_drum_input_line_parent_class)->set_channel(line, channel);

  drum_input_line = AGS_DRUM_INPUT_LINE(line);

#ifdef AGS_DEBUG
  g_message("ags_drum_input_line_set_channel - channel: %u\0",
	    channel->line);
#endif

  if(line->channel != NULL){
    line->flags &= (~AGS_LINE_MAPPED_RECALL);
  }

  if(channel != NULL){
    if(channel->pattern == NULL){
      channel->pattern = g_list_alloc();
      channel->pattern->data = (gpointer) ags_pattern_new();
      ags_pattern_set_dim((AgsPattern *) channel->pattern->data, 4, 12, 64);
    }

    if((AGS_LINE_PREMAPPED_RECALL & (line->flags)) == 0){
      ags_drum_input_line_map_recall(drum_input_line, 0);
      ags_line_find_port(line);
    }else{
      //TODO:JK: make it advanced
      /* reset edit button */
      if(line->channel->line == 0){
	AgsDrum *drum;
	GtkToggleButton *selected_edit_button;

	drum = (AgsDrum *) gtk_widget_get_ancestor(GTK_WIDGET(line),
						   AGS_TYPE_DRUM);

	drum->selected_pad = AGS_DRUM_INPUT_PAD(gtk_container_get_children((GtkContainer *) drum->input_pad)->data);
	drum->selected_edit_button = drum->selected_pad->edit;
	gtk_toggle_button_set_active((GtkToggleButton *) drum->selected_edit_button, TRUE);
      }
    }
  }
}
示例#13
0
/**
 * i3ipc_con_descendents:
 * @self: an #i3ipcCon
 *
 * Returns: (transfer container) (element-type i3ipcCon): a list of descendent nodes
 */
GList *i3ipc_con_descendents(i3ipcCon *self) {
  GList *retval;

  /* if the con is a leaf, there is nothing to do */
  if (!self->priv->nodes && !self->priv->floating_nodes)
    return NULL;

  /* the list has to have a first element for some reason. */
  retval = g_list_alloc();

  g_list_foreach(self->priv->nodes, i3ipc_con_collect_descendents_func, retval);
  g_list_foreach(self->priv->floating_nodes, i3ipc_con_collect_descendents_func, retval);

  /* XXX: I hope this doesn't leak */
  retval = g_list_remove_link(retval, g_list_first(retval));

  return retval;
}
示例#14
0
/***************************************************************
* ToggleRadioButtonNew関数                                     *
* ラジオアクションを設定したトグルボタンウィジェットを作成     *
* 引数                                                         *
* list			: ボタンリストの入ったGList                    *
*				  先頭のボタンはNULLの入ったlistを渡す         *
*				  g_list_freeしないこと                        *
* callback_func	: ボタンが有効状態になった時のコールバック関数 *
* callback_data	: コールバック関数に渡すデータ                 *
* 返り値                                                       *
*	ボタンウィジェット                                         *
***************************************************************/
GtkWidget* ToggleRadioButtonNew(
	GList** list,
	void (*callback_func)(GtkWidget* button, void* data),
	void* callback_data
)
{
	TOGGLE_RADIO_BUTTON_DATA *data;
	GtkWidget *button;
	GList *button_list;

	if(list == NULL)
	{
		return NULL;
	}
	else if(*list == NULL)
	{
		data = (TOGGLE_RADIO_BUTTON_DATA*)MEM_ALLOC_FUNC(sizeof(*data));
		(void)memset(data, 0, sizeof(*data));
		*list = data->button_list = g_list_alloc();
		(*list)->data = (gpointer)(button = gtk_toggle_button_new());
		g_object_set_data(G_OBJECT(button), "widget_data", data);
		(void)g_signal_connect_swapped(G_OBJECT(button), "destroy",
			G_CALLBACK(OnDestroyToggleRadioButton), data);
		data->callback_func = callback_func;
		data->callback_data = callback_data;
		(void)g_signal_connect(G_OBJECT(button), "toggled",
			G_CALLBACK(OnToggledToggleRadioButton), data);

		return button;
	}

	data = (TOGGLE_RADIO_BUTTON_DATA*)g_object_get_data(G_OBJECT((*list)->data), "widget_data");
	button_list = *list;
	while(button_list->next != NULL)
	{
		button_list = button_list->next;
	}
	(void)g_list_append(button_list, (gpointer)(button = gtk_toggle_button_new()));
	(void)g_signal_connect(G_OBJECT(button), "toggled",
		G_CALLBACK(OnToggledToggleRadioButton), data);

	return button;
}
示例#15
0
/**
 * i3ipc_con_workspaces:
 * @self: an #i3ipcCon
 *
 * Returns: (transfer container) (element-type i3ipcCon): a list of workspaces in the tree
 */
GList *i3ipc_con_workspaces(i3ipcCon *self) {
  GList *retval;
  i3ipcCon *root;

  root = i3ipc_con_root(self);

  /* this could happen for incomplete trees */
  if (!root->priv->nodes)
    return NULL;

  /* the list has to have a first element for some reason. */
  retval = g_list_alloc();

  g_list_foreach(root->priv->nodes, i3ipc_con_collect_workspaces_func, retval);

  /* XXX: I hope this doesn't leak */
  retval = g_list_remove_link(retval, g_list_first(retval));

  return retval;
}
示例#16
0
static void
rsvg_rc_style_merge (GtkRcStyle *dest,
		       GtkRcStyle *src)
{
  if (RSVG_IS_RC_STYLE (src))
    {
      RsvgRcStyle *rsvg_dest = RSVG_RC_STYLE (dest);
      RsvgRcStyle *rsvg_src = RSVG_RC_STYLE (src);
      GList *tmp_list1, *tmp_list2;
      
      if (rsvg_src->img_list)
	{
	  /* Copy src image list and append to dest image list */
	  
	  tmp_list2 = g_list_last (rsvg_dest->img_list);
	  tmp_list1 = rsvg_src->img_list;
	  
	  while (tmp_list1)
	    {
	      if (tmp_list2)
		{
		  tmp_list2->next = g_list_alloc();
		  tmp_list2->next->data = tmp_list1->data;
		  tmp_list2->next->prev = tmp_list2;
		  
		  tmp_list2 = tmp_list2->next;
		}
	      else
		{
		  rsvg_dest->img_list = g_list_append (NULL, tmp_list1->data);
		  tmp_list2 = rsvg_dest->img_list;
		}
	      
	      theme_image_ref (tmp_list1->data);
	      tmp_list1 = tmp_list1->next;
	    }
	}
    }

  parent_class->merge (dest, src);
}
示例#17
0
文件: pixbuf-rc-style.c 项目: krh/gtk
static void
pixbuf_rc_style_merge (GtkRcStyle *dest,
                       GtkRcStyle *src)
{
    if (PIXBUF_IS_RC_STYLE (src))
    {
        PixbufRcStyle *pixbuf_dest = PIXBUF_RC_STYLE (dest);
        PixbufRcStyle *pixbuf_src = PIXBUF_RC_STYLE (src);
        GList *tmp_list1, *tmp_list2;

        if (pixbuf_src->img_list)
        {
            /* Copy src image list and append to dest image list */

            tmp_list2 = g_list_last (pixbuf_dest->img_list);
            tmp_list1 = pixbuf_src->img_list;

            while (tmp_list1)
            {
                if (tmp_list2)
                {
                    tmp_list2->next = g_list_alloc();
                    tmp_list2->next->data = tmp_list1->data;
                    tmp_list2->next->prev = tmp_list2;

                    tmp_list2 = tmp_list2->next;
                }
                else
                {
                    pixbuf_dest->img_list = g_list_append (NULL, tmp_list1->data);
                    tmp_list2 = pixbuf_dest->img_list;
                }

                theme_image_ref (tmp_list1->data);
                tmp_list1 = tmp_list1->next;
            }
        }
    }

    parent_class->merge (dest, src);
}
示例#18
0
static void
_list_append2(GList **head_p, GList **tail_p, gpointer data)
{
    GList *head = *head_p;
    GList *tail = *tail_p;
    GList *elem;

    g_return_if_fail((head == NULL) == (tail == NULL));
    g_return_if_fail((tail == NULL) || (tail->next == NULL));

    elem = g_list_alloc();
    elem->data = data;
    elem->prev = tail;
    elem->next = NULL;

    if (head) {
        tail->next = elem;
        *tail_p = elem;
    } else
        *head_p = *tail_p = elem;
}
static inline GObjectNotifyQueue*
g_object_notify_queue_freeze (GObject		   *object,
			      GObjectNotifyContext *context)
{
  GObjectNotifyQueue *nqueue;

  nqueue = g_datalist_id_get_data (&object->qdata, context->quark_notify_queue);
  if (!nqueue)
    {
      nqueue = (void*) g_list_alloc ();
      memset (nqueue, 0, sizeof (*nqueue));
      nqueue->context = context;
      g_datalist_id_set_data_full (&object->qdata, context->quark_notify_queue,
				   nqueue, g_object_notify_queue_free);
    }

  g_return_val_if_fail (nqueue->freeze_count < 65535, nqueue);
  nqueue->freeze_count++;

  return nqueue;
}
示例#20
0
TABVIEW *ZJ_Create_TabView(int x,int y,int width,int height)
{
	ptabview newtabview= (TABVIEW*)malloc(sizeof(TABVIEW));
	//newtabview->TabViewWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	/*newtabview->container = gtk_container_new(*/
	newtabview->fistlist = g_list_alloc();
	newtabview->fistlist->data = NULL;
	newtabview->TabViewFixed = gtk_fixed_new();
	newtabview->PageFixed = gtk_fixed_new();
	newtabview->pos = TV_POS_TOP;
	newtabview->focuslist = NULL;
	newtabview->current_page = NULL;
	if(x<0)
		x = 0;
	if(y<0)
		y = 0;
	if(width<=0)
		width = DEFAULT_TABVIEWWINDOW_W;
	if(height<=0)
		height = DEFAULT_TABVIEWWINDOW_H;
	newtabview->width = width;
	newtabview->height = height;
	newtabview->x = x;
	newtabview->y = y;
	newtabview->offset1 = 5;
	newtabview->offset2 = 5;
	newtabview->inborder = 0;
	newtabview->active_bg_Img_file = NULL;
	newtabview->normal_bg_Img_file = NULL;
	newtabview->prelight_bg_Img_file = NULL;
	gtk_widget_set_usize((GtkWidget *)(newtabview->TabViewFixed),width,height);
	gtk_widget_set_uposition((GtkWidget *)(newtabview->TabViewFixed),x,y);
	//gtk_widget_set_usize((GtkWidget *)(newtabview->TabViewFixed),width,height);

	
	gtk_widget_set_uposition((GtkWidget *)(newtabview->TabViewFixed),newtabview->offset1,y);
	gtk_container_add((GtkContainer*)newtabview->TabViewFixed,(GtkWidget *)newtabview->PageFixed);
	return newtabview;
}
示例#21
0
/**
 * mate_druid_insert_page:
 * @druid: A #MateDruid widget.
 * @back_page: The page prior to the page to be inserted.
 * @page: The page to insert.
 *
 * Description: This will insert @page after @back_page into the list of
 * internal pages that the @druid has.  If @back_page is not present in the
 * list or %NULL, @page will be prepended to the list.  Since #MateDruid is
 * just a container, you will need to also call gtk_widget_show() on the page,
 * otherwise the page will not be shown.
 **/
void
mate_druid_insert_page (MateDruid *druid,
			 MateDruidPage *back_page,
			 MateDruidPage *page)
{
	GList *list;

	g_return_if_fail (druid != NULL);
	g_return_if_fail (MATE_IS_DRUID (druid));
	g_return_if_fail (page != NULL);
	g_return_if_fail (MATE_IS_DRUID_PAGE (page));

	list = g_list_find (druid->_priv->children, back_page);
	if (list == NULL) {
		druid->_priv->children = g_list_prepend (druid->_priv->children, page);
	} else {
		GList *new_el = g_list_alloc ();
		new_el->next = list->next;
		new_el->prev = list;
		if (new_el->next)
			new_el->next->prev = new_el;
		new_el->prev->next = new_el;
		new_el->data = (gpointer) page;
	}
	gtk_widget_set_parent (GTK_WIDGET (page), GTK_WIDGET (druid));

	if (GTK_WIDGET_REALIZED (GTK_WIDGET (druid)))
		gtk_widget_realize (GTK_WIDGET (page));

	if (GTK_WIDGET_VISIBLE (GTK_WIDGET (druid)) && GTK_WIDGET_VISIBLE (GTK_WIDGET (page))) {
		if (GTK_WIDGET_MAPPED (GTK_WIDGET (page)))
			gtk_widget_unmap (GTK_WIDGET (page));
		gtk_widget_queue_resize (GTK_WIDGET (druid));
	}

	/* if it's the first and only page, we want to bring it to the foreground. */
	if (druid->_priv->children->next == NULL)
		mate_druid_set_page (druid, page);
}
示例#22
0
void
ags_matrix_set_pads(AgsAudio *audio, GType type,
		    guint pads, guint pads_old,
		    gpointer data)
{
  AgsMachine *machine;
  AgsMatrix *matrix;
  AgsChannel *channel, *source;
  AgsAudioSignal *audio_signal;
  guint i, j;
  gboolean grow;

  GValue value = {0,};

  if(pads == pads_old){
    return;
  }
  
  matrix = (AgsMatrix *) audio->machine_widget;
  machine = AGS_MACHINE(matrix);

  if(type == AGS_TYPE_INPUT){
    if(pads < AGS_MATRIX_OCTAVE){
      gtk_widget_set_size_request((GtkWidget *) matrix->drawing_area,
				  32 * AGS_MATRIX_CELL_WIDTH +1,
				  pads * AGS_MATRIX_CELL_HEIGHT +1);
    }else if(pads_old < AGS_MATRIX_OCTAVE){
      gtk_widget_set_size_request((GtkWidget *) matrix->drawing_area,
				  32 * AGS_MATRIX_CELL_WIDTH +1,
				  AGS_MATRIX_OCTAVE * AGS_MATRIX_CELL_HEIGHT +1);
    }
  }

  if(pads_old == pads)
    return;
  if(pads_old < pads)
    grow = TRUE;
  else
    grow = FALSE;

  if(type == AGS_TYPE_INPUT){
    AgsPattern *pattern;
    GList *list, *notation;

    if(grow){
      /* create pattern */
      source = ags_channel_nth(audio->input, pads_old);

      while(source != NULL){
	if(source->pattern == NULL){
	  source->pattern = g_list_alloc();
	  source->pattern->data = (gpointer) ags_pattern_new();
	  ags_pattern_set_dim((AgsPattern *) source->pattern->data, 1, 9, 32);
	}
	
	source = source->next;
      }

      if((AGS_MACHINE_MAPPED_RECALL & (machine->flags)) != 0){
	ags_matrix_input_map_recall(matrix,
				    pads_old);
      }
    }else{
    }
  }else{
    if(grow){
      AgsChannel *current, *output;
      GList *recall;
      GList *list;
      guint stop;

      source = ags_channel_nth(audio->output, pads_old);

      if(source != NULL){
	AgsAudioSignal *audio_signal;
	
	AgsSoundcard *soundcard;

	gdouble delay;
	guint stop;
	
	soundcard = AGS_SOUNDCARD(AGS_AUDIO(source->audio)->soundcard);

	delay = ags_soundcard_get_delay(soundcard);

	stop = (guint) ceil(16.0 * delay * exp2(8.0 - 4.0) + 1.0);

	audio_signal = ags_audio_signal_new(soundcard,
					    source->first_recycling,
					    NULL);
	audio_signal->flags |= AGS_AUDIO_SIGNAL_TEMPLATE;
	//	ags_audio_signal_stream_resize(audio_signal,
	//			       stop);
	ags_recycling_add_audio_signal(source->first_recycling,
				       audio_signal);

	if((AGS_MACHINE_MAPPED_RECALL & (machine->flags)) != 0){
	  ags_matrix_output_map_recall(matrix,
				       pads_old);
	}
      }
    }else{
    }
  }
}
示例#23
0
static GList *
priority_segment_alloc_node (TrackerPriorityQueue *queue,
                             gint                  priority)
{
	PrioritySegment *segment = NULL;
	gboolean found = FALSE;
	gint l, r, c;
	GList *node;

	/* Perform binary search to find out the segment for
	 * the given priority, create one if it isn't found.
	 */
	l = 0;
	r = queue->segments->len - 1;

	while (queue->segments->len > 0 && !found) {
		c = (r + l) / 2;
		segment = &g_array_index (queue->segments, PrioritySegment, c);

		if (segment->priority == priority) {
			found = TRUE;
			break;
		} else if (segment->priority > priority) {
			r = c - 1;
		} else if (segment->priority < priority) {
			l = c + 1;
		}

		if (l > r) {
			break;
		}
	}

	if (found) {
		/* Element found, append at the end of segment */
		g_assert (segment != NULL);
		g_assert (segment->priority == priority);

		g_queue_insert_after (&queue->queue, segment->last_elem, NULL);
		node = segment->last_elem = segment->last_elem->next;
	} else {
		PrioritySegment new_segment = { 0 };

		new_segment.priority = priority;

		if (segment) {
			g_assert (segment->priority != priority);

			/* Binary search got to one of the closest results,
			 * but we may have come from either of both sides,
			 * so check whether we have to insert after the
			 * segment we got.
			 */
			if (segment->priority > priority) {
				/* We have to insert to the left of this element */
				g_queue_insert_before (&queue->queue, segment->first_elem, NULL);
				node = segment->first_elem->prev;
			} else {
				/* We have to insert to the right of this element */
				g_queue_insert_after (&queue->queue, segment->last_elem, NULL);
				node = segment->last_elem->next;
				c++;
			}

			new_segment.first_elem = new_segment.last_elem = node;
			g_array_insert_val (queue->segments, c, new_segment);
		} else {
			/* Segments list has 0 elements */
			g_assert (queue->segments->len == 0);
			g_assert (g_queue_get_length (&queue->queue) == 0);

			node = g_list_alloc ();
			g_queue_push_head_link (&queue->queue, node);
			new_segment.first_elem = new_segment.last_elem = node;

			g_array_append_val (queue->segments, new_segment);
		}
	}

	return node;
}
示例#24
0
/* parser for a single EventInfo node */
void parseEventInfo (xmlDocPtr doc, xmlNodePtr cur)
{
  xmlChar *key;
  xmlChar *attribute;
  cur = cur->xmlChildrenNode;
  struct eventinfo *eventinfonode;
  int key_counter = 0;  
  
  eventinfonode = (struct eventinfo*) g_malloc (
    sizeof (struct eventinfo));
  
  eventlist = g_list_append (eventlist, (struct eventinfo*) eventinfonode);
  eventinfonode->modifier = NULL;
  
  while (cur != NULL)
  {
    /* found a <key>-value */
    if ((!xmlStrcmp (cur->name, (const xmlChar *) "key")))
    {
      /* create only a list if there are modifiers */      
      if (key_counter == 0)
      {	
	eventinfonode->modifier = g_list_alloc ();
      }
      
      key = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1);
      eventinfonode->modifier = g_list_append (eventinfonode->modifier,
					       (int*) key_char2int ( (char*) key));
      xmlFree (key);
      key_counter++;
    }   
    
    /* found a <exec>-value */
    if ((!xmlStrcmp (cur->name, (const xmlChar *) "exec")))
    {            
      key = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1);
      eventinfonode->exec_app = strdup ((char*) key);

      /* DIRTY HACK: use better data structure */
      /*attribute = xmlGetProp(cur, "scroll");
      
      if (!(strcmp (g_ascii_strup (key, -1), "TRUE")))
	eventinfonode->exec_app_attribute = 1;
      else
      eventinfonode->exec_app_attribute = 2;*/
      
      xmlFree (key);
    }

    /* found a <button>-value */
    if ((!xmlStrcmp (cur->name, (const xmlChar *) "button")))
    {
      int key_val;
      
      key = xmlNodeListGetString (doc, cur->xmlChildrenNode, 1);
      key_val = atoi (key);

      if ((key_val >= 1) && (key_val <= 3))
      {
	eventinfonode->button = key_val;
        eventinfonode->scroll = 0;
      }
      else
      {
	eventinfonode->button = button_char2int (key);
        eventinfonode->scroll = 1;
      }
      xmlFree (key);
    }
    
    cur = cur->next;
  }
  return;
}
示例#25
0
    GtkWidget  *statusAlign;
    GtkWidget  *statusBar;
    const char *statusMessage;
    int         loadPercent;
    int         bytesLoaded;
    int         maxBytesLoaded;
    char       *tempMessage;
    gboolean menuBarOn;
    gboolean toolBarOn;
    gboolean locationBarOn;
    gboolean statusBarOn;

} TestGtkBrowser;

// the list of browser windows currently open
GList *browser_list = g_list_alloc();

static TestGtkBrowser *new_gtk_browser    (guint32 chromeMask);
static void            set_browser_visibility (TestGtkBrowser *browser,
        gboolean visibility);

static int num_browsers = 0;

// callbacks from the UI
static void     back_clicked_cb    (GtkButton   *button,
                                    TestGtkBrowser *browser);
static void     stop_clicked_cb    (GtkButton   *button,
                                    TestGtkBrowser *browser);
static void     forward_clicked_cb (GtkButton   *button,
                                    TestGtkBrowser *browser);
static void     reload_clicked_cb  (GtkButton   *button,
示例#26
0
/* parser for the complete xml file */
GList *parseDoc (char *docname)
{
  xmlDocPtr doc;
  xmlNodePtr cur;
    
  xmlParserCtxtPtr ctxt;
  
  eventlist = g_list_alloc ();		 /* allocates memory for new list */

  if (getValidate() == TRUE)
  {
    ctxt = xmlCreateFileParserCtxt(docname);

    if (ctxt == NULL)
    {    
      exit (1);
    }
 
    ctxt->validate = 1;			 /* check the XML's DTD */
    xmlParseDocument(ctxt);

    if (!ctxt->valid)
    {
      g_print ("Please correct this problem or grootevent isn't able to run.\n"
	       "Hint: You could also disable validating (--help for more infos)\n");
      exit (1);
    }
  } 

  doc = xmlParseFile (docname);
  
  if (doc == NULL)
  {
    fprintf (stderr, "Document not parsed successfully. \n");
    return NULL;
  }

  cur = xmlDocGetRootElement (doc);

  if (cur == NULL)
  {
    fprintf (stderr, "empty document\n");
    xmlFreeDoc (doc);
    return NULL;
  }

  if (xmlStrcmp (cur->name, (const xmlChar *) "grootevent"))
  {
    fprintf (stderr, "document of the wrong type, root node != grootevent\n");
    xmlFreeDoc (doc);
    return NULL;
  }

  cur = cur->xmlChildrenNode;
  while (cur != NULL)
  {
    if ((!xmlStrcmp (cur->name, (const xmlChar *) "eventinfo")))
    {
      parseEventInfo (doc, cur);
    }

    cur = cur->next;
  }

  xmlFreeDoc (doc);
  return eventlist;
}
示例#27
0
void reinit_command_list_send() {
	free_commands_list_send();
	command_list_send = g_list_alloc();
}
示例#28
0
文件: combobox.cpp 项目: beanhome/dev
int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
                              unsigned int pos,
                              void **clientData,
                              wxClientDataType type)
{
    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );

    DisableEvents();

    GtkWidget *list = GTK_COMBO(m_widget)->list;

    GtkRcStyle *style = CreateWidgetStyle();

    const unsigned int count = items.GetCount();
    for( unsigned int i = 0; i < count; ++i, ++pos )
    {
        GtkWidget *
            list_item = gtk_list_item_new_with_label( wxGTK_CONV( items[i] ) );

        if ( pos == GetCount() )
        {
            gtk_container_add( GTK_CONTAINER(list), list_item );
        }
        else // insert, not append
        {
            GList *gitem_list = g_list_alloc ();
            gitem_list->data = list_item;
            gtk_list_insert_items( GTK_LIST (list), gitem_list, pos );
        }

        if (GTK_WIDGET_REALIZED(m_widget))
        {
            gtk_widget_realize( list_item );
            gtk_widget_realize( GTK_BIN(list_item)->child );

            if (style)
            {
                gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
                GtkBin *bin = GTK_BIN( list_item );
                GtkWidget *label = GTK_WIDGET( bin->child );
                gtk_widget_modify_style( label, style );
            }

        }

        gtk_widget_show( list_item );

        if ( m_clientDataList.GetCount() < GetCount() )
            m_clientDataList.Insert( pos, NULL );
        if ( m_clientObjectList.GetCount() < GetCount() )
            m_clientObjectList.Insert( pos, NULL );

        AssignNewItemClientData(pos, clientData, i, type);
    }

    if ( style )
        gtk_rc_style_unref( style );

    EnableEvents();

    InvalidateBestSize();

    return pos - 1;
}
示例#29
0
void wxListBox::GtkAddItem( const wxString &item, int pos )
{
    wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );

    GtkWidget *list_item;

    wxString label(item);
#if wxUSE_CHECKLISTBOX
    if (m_hasCheckBoxes)
    {
        label.Prepend(wxCHECKLBOX_STRING);
    }
#endif // wxUSE_CHECKLISTBOX

    list_item = gtk_list_item_new_with_label( wxGTK_CONV( label ) );

    GList *gitem_list = g_list_alloc ();
    gitem_list->data = list_item;

    if (pos == -1)
        gtk_list_append_items( GTK_LIST (m_list), gitem_list );
    else
        gtk_list_insert_items( GTK_LIST (m_list), gitem_list, pos );

    gtk_signal_connect_after( GTK_OBJECT(list_item), "select",
      GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );

    if (HasFlag(wxLB_MULTIPLE) || HasFlag(wxLB_EXTENDED))
        gtk_signal_connect_after( GTK_OBJECT(list_item), "deselect",
          GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback), (gpointer)this );

    gtk_signal_connect( GTK_OBJECT(list_item),
                        "button_press_event",
                        (GtkSignalFunc)gtk_listbox_button_press_callback,
                        (gpointer) this );

    gtk_signal_connect_after( GTK_OBJECT(list_item),
                        "button_release_event",
                        (GtkSignalFunc)gtk_listbox_button_release_callback,
                        (gpointer) this );

    gtk_signal_connect( GTK_OBJECT(list_item),
                           "key_press_event",
                           (GtkSignalFunc)gtk_listbox_key_press_callback,
                           (gpointer)this );


    gtk_signal_connect( GTK_OBJECT(list_item), "focus_in_event",
            GTK_SIGNAL_FUNC(gtk_listitem_focus_in_callback), (gpointer)this );

    gtk_signal_connect( GTK_OBJECT(list_item), "focus_out_event",
            GTK_SIGNAL_FUNC(gtk_listitem_focus_out_callback), (gpointer)this );

    ConnectWidget( list_item );

    if (GTK_WIDGET_REALIZED(m_widget))
    {
        gtk_widget_show( list_item );

        gtk_widget_realize( list_item );
        gtk_widget_realize( GTK_BIN(list_item)->child );

#if wxUSE_TOOLTIPS
        if (m_tooltip) m_tooltip->Apply( this );
#endif
    }

    // Apply current widget style to the new list_item
    GtkRcStyle *style = CreateWidgetStyle();
    if (style)
    {
        gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
        GtkBin *bin = GTK_BIN( list_item );
        gtk_widget_modify_style( GTK_WIDGET( bin->child ), style );
        gtk_rc_style_unref( style );
    }
}
示例#30
0
static void
gegl_tile_backend_swap_entry_destroy (GeglTileBackendSwap *self,
                                      SwapEntry           *entry)
{
  guint64  start, end;
  gint     tile_size = gegl_tile_backend_get_tile_size (GEGL_TILE_BACKEND (self));
  GList   *hlink;

  if (entry->link)
    {
      GList *link;

      g_mutex_lock (&mutex);

      if ((link = entry->link))
        {
          ThreadParams *queued_op = link->data;
          g_queue_delete_link (queue, link);
          gegl_tile_unref (queued_op->tile);
          g_slice_free (ThreadParams, queued_op);
        }

      g_mutex_unlock (&mutex);
    }

  start = entry->offset;
  end = start + tile_size;

  if ((hlink = gap_list))
    while (hlink)
      {
        GList *llink = hlink->prev;
        SwapGap *lgap, *hgap;

        if (llink)
          lgap = llink->data;

        hgap = hlink->data;

        /* attempt to merge lower, upper and this gap */
        if (llink != NULL && lgap->end == start &&
            hgap->start == end)
          {
            llink->next = hlink->next;
            if (hlink->next)
              hlink->next->prev = llink;
            lgap->end = hgap->end;

            g_slice_free (SwapGap, hgap);
            hlink->next = NULL;
            hlink->prev = NULL;
            g_list_free (hlink);
            break;
          }
        /* attempt to merge with upper gap */
        else if (hgap->start == end)
          {
            hgap->start = start;
            break;
          }
        /* attempt to merge with lower gap */
        else if (llink != NULL && lgap->end == start)
          {
            lgap->end = end;
            break;
          }
        /* create new gap */
        else if (hgap->start > end)
          {
            lgap = gegl_tile_backend_swap_gap_new (start, end);
            gap_list = g_list_insert_before (gap_list, hlink, lgap);
            break;
          }

        /* if there's no more elements in the list after this */
        else if (hlink->next == NULL)
          {
            /* attempt to merge with the last gap */
            if (hgap->end == start)
              {
                hgap->end = end;
              }
            /* create a new gap in the end of the list */
            else
              {
                GList *new_link;
                hgap = gegl_tile_backend_swap_gap_new (start, end);
                new_link = g_list_alloc ();
                new_link->next = NULL;
                new_link->prev = hlink;
                new_link->data = hgap;
                hlink->next = new_link;
              }
            break;
          }

        hlink = hlink->next;
      }
  else
    gap_list = g_list_prepend (NULL,
                               gegl_tile_backend_swap_gap_new (start, end));

  g_hash_table_remove (self->index, entry);
  g_slice_free (SwapEntry, entry);
}