コード例 #1
0
ファイル: my-atk-text.c プロジェクト: GNOME/pyatspi2
void correct_selections_after_delete(MyAtkText *text, gint position, gint length)
{
    gint i;
    GArray* selections = text->selections;
    for(i = selections->len - 1; i >=0; i--)
    {
        TextSelection* sel  = &g_array_index(selections, TextSelection, i);
        if(sel->start_offset >= position)
        {
             if(sel->start_offset >= position + length)
             {
                sel->start_offset-= length;
                sel->end_offset-= length;
             }
             //position <= sel->start_offset < position + length
             else if(sel->end_offset > position + length)
             {
                sel->start_offset = position;
                sel->end_offset -= length;
             }
             else
             {
                g_array_remove_index(selections, i);
             }
             continue;  
        }
        /*sel->start_offset < position*/
        if(sel->end_offset > position + length) sel->end_offset-= length;
        else if(sel->end_offset > position) sel->end_offset = position;
        break;
    }
}
コード例 #2
0
ファイル: tracker.c プロジェクト: giraldeau/sysprof
static void
create_map (state_t *state, new_map_t *new_map)
{
    process_t *process;
    map_t map;
    int i;
    pid_t pid = GET_PID (new_map->header);

    process = g_hash_table_lookup (
	state->processes_by_pid, GINT_TO_POINTER (pid));

    if (!process)
	return;

    map.filename = g_strdup (new_map->filename);
    map.start = new_map->start;
    map.end = new_map->end;
    map.offset = new_map->offset;
    map.inode = new_map->inode;

    /* Remove existing maps that overlap the new one */
    for (i = 0; i < process->maps->len; ++i)
    {
        map_t *m = &g_array_index (process->maps, map_t, i);

        if (m->start < map.end && m->end > map.start)
        {
            g_free (m->filename);

	    g_array_remove_index (process->maps, i);
        }
    }

    g_array_append_vals (process->maps, &map, 1);
}
コード例 #3
0
static void _insert_array(GArray *garray, ms_scan_data_t *insert_data)
{
	ms_scan_data_t *data;
	bool insert_ok = false;
	int len = garray->len;
	int i;

	MS_DBG("the length of array : %d", len);
	MS_DBG("path : %s", insert_data->path);
	MS_DBG("scan_type : %d", insert_data->scan_type);

	if (insert_data->scan_type == POWEROFF) {
		g_array_prepend_val(garray, insert_data);
	} else {
		for (i=0; i < len; i++) {
			data = g_array_index(garray, ms_scan_data_t*, i);

			if (data->scan_type != POWEROFF) {
				if (data->storage_type == insert_data->storage_type) {
					if(data->scan_type > insert_data->scan_type) {
						g_array_remove_index (garray, i);
						g_array_insert_val(garray, i, insert_data);
						insert_ok =  true;
					}
				}
			}
		}

		if (insert_ok == false)
			g_array_append_val(garray, insert_data);
	}
}
コード例 #4
0
CF_EXPORT void
rwsched_tasklet_CFRunLoopTimerInvalidate(rwsched_tasklet_ptr_t sched_tasklet,
        rwsched_CFRunLoopTimerRef rwsched_timer)
{
    // Validate input paraemters
    RW_CF_TYPE_VALIDATE(sched_tasklet, rwsched_tasklet_ptr_t);
    rwsched_instance_ptr_t instance = sched_tasklet->instance;
    RW_CF_TYPE_VALIDATE(instance, rwsched_instance_ptr_t);
    RW_CF_TYPE_VALIDATE(rwsched_timer, rwsched_CFRunLoopTimerRef);

    rwsched_timer->invalidate_called = 1;
#if 1
    int i;
    for (i = 1 ; i < sched_tasklet->cftimer_array->len ; i++) {
        if (g_array_index(sched_tasklet->cftimer_array, rwsched_CFRunLoopTimerRef, i) == rwsched_timer) {
            g_array_remove_index (sched_tasklet->cftimer_array, i);
            break;
        }
    }
#else
    RW_ASSERT(rwsched_timer->index != 0);
    RW_ASSERT(sched_tasklet->cftimer_array->len > rwsched_timer->index);
    g_array_index(sched_tasklet->cftimer_array, rwsched_CFRunLoopTimerRef, rwsched_timer->index) = NULL;
    rwsched_timer->index = 0;
#endif
    // Call the native CFRunLoop function
    CFRunLoopTimerInvalidate(rwsched_timer->cf_object);
}
コード例 #5
0
void ManageInterfacesDialog::saveLocalCommentChanges(QTreeWidgetItem* item)
{
    guint i;
    interface_t device;

    if (!item) {
        return;
    }

    QString name = item->text(col_l_local_name_);
    QString comment = item->text(col_l_comment_);
    /* See if this is the currently selected capturing device */

    for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
        device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
        if (name.compare(device.name)) {
            continue;
        }

        g_free(device.display_name);
        // XXX The GTK+ UI uses the raw device name instead of the friendly name.
        // This seems to make more sense.
        gchar *if_string = device.friendly_name ? device.friendly_name : device.name;
        if (comment.isEmpty()) {
            device.display_name = g_strdup(if_string);
        } else {
            device.display_name = qstring_strdup(QString("%1: %2").arg(comment).arg(if_string));
        }
        global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
        g_array_insert_val(global_capture_opts.all_ifaces, i, device);
    }
}
コード例 #6
0
ファイル: garray.c プロジェクト: jmckaskill/subversion
GByteArray* g_byte_array_remove_index (GByteArray *array,
				       guint index)
{
  g_array_remove_index((GArray*) array, index);

  return array;
}
コード例 #7
0
void
hide_interface(gchar* new_hide)
{
    gchar       *tok;
    guint       i;
    interface_t device;
    gboolean    found = FALSE;
    GList       *hidden_devices = NULL, *entry;
    if (new_hide != NULL) {
        for (tok = strtok (new_hide, ","); tok; tok = strtok(NULL, ",")) {
            hidden_devices = g_list_append(hidden_devices, tok);
        }
    }
    for (i = 0; i < global_capture_opts.all_ifaces->len; i++) {
        device = g_array_index(global_capture_opts.all_ifaces, interface_t, i);
        found = FALSE;
        for (entry = hidden_devices; entry != NULL; entry = g_list_next(entry)) {
            if (strcmp((char *)entry->data, device.name)==0) {
                device.hidden = TRUE;
                if (device.selected) {
                    device.selected = FALSE;
                    global_capture_opts.num_selected--;
                }
                found = TRUE;
                break;
            }
        }
        if (!found) {
            device.hidden = FALSE;
        }
        global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, i);
        g_array_insert_val(global_capture_opts.all_ifaces, i, device);
    }
}
コード例 #8
0
gboolean ms_scan_thread(void *data)
{
	ms_scan_data_t *scan_data = NULL;
	ms_scan_data_t *insert_data;
	GArray *garray = NULL;
	bool res;
	int length;
	int err;
	void **handle = NULL;
	ms_storage_type_t storage_type;
	ms_dir_scan_type_t scan_type;

	/*create array for processing overlay data*/
	garray = g_array_new (FALSE, FALSE, sizeof (ms_scan_data_t *));
	if (garray == NULL) {
		MS_DBG_ERR("g_array_new error");
		return false;
	}

	while (1) {
		length  = g_async_queue_length(scan_queue);

		/*updating requests remain*/
		if (garray->len != 0 && length == 0) {
			scan_data = g_array_index(garray, ms_scan_data_t*, 0);
			g_array_remove_index (garray, 0);
			if (scan_data->scan_type == POWEROFF) {
				MS_DBG("power off");
				goto POWER_OFF;
			}
		} else if (length != 0) {
コード例 #9
0
void
tracker_priority_queue_remove_node (TrackerPriorityQueue *queue,
                                    GList                *node)
{
	guint i;

	g_return_if_fail (queue != NULL);

	/* Check if it is the first or last of a segment */
	for (i = 0; i < queue->segments->len; i++) {
		PrioritySegment *segment;

		segment = &g_array_index (queue->segments, PrioritySegment, i);

		if (segment->first_elem == node) {
			if (segment->last_elem == node)
				g_array_remove_index (queue->segments, i);
			else
				segment->first_elem = node->next;
			break;
		}

		if (segment->last_elem == node) {
			segment->last_elem = node->prev;
			break;
		}
	}

	g_queue_delete_link (&queue->queue, node);
}
コード例 #10
0
ファイル: misc2_callbacks.c プロジェクト: kashifsoofi/bygfoot
G_MODULE_EXPORT void
on_button_transfer_no_clicked          (GtkButton       *button,
                                        gpointer         user_data)
{
#ifdef DEBUG
    printf("on_button_transfer_no_clicked\n");
#endif

    gint len = 1;

    transoff(stat2, 0).status = TRANSFER_OFFER_REJECTED;
    if(transoff(stat2, 0).tm == current_user.tm)
    {
	g_array_remove_index(trans(stat2).offers, 0);
	len = 0;
    }

    if(trans(stat2).offers->len > len)
	transfer_offers_notify(&trans(stat2), FALSE);

    treeview_show_user_player_list();
    game_gui_set_main_window_header();
    on_button_transfers_clicked(NULL, NULL);

    window_destroy(&window.transfer_dialog);
}
コード例 #11
0
static void
gtk_iface_mon_event_cb(const char *iface, int up)
{
    int present = 0;
    guint ifs, j;
    interface_t device;
    interface_options interface_opts;

    for (ifs = 0; ifs < global_capture_opts.all_ifaces->len; ifs++) {
      device = g_array_index(global_capture_opts.all_ifaces, interface_t, ifs);
      if (!strcmp(device.name, iface)) {
          present = 1;
          if (!up) {
          	 for (j = 0; j < global_capture_opts.ifaces->len; j++) {
                interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, j);
                if (strcmp(interface_opts.name, device.name) == 0) {
                	g_array_remove_index(global_capture_opts.ifaces, j);
                }
             }
          }
        }
    }

    if (present == up)
        return;

    refresh_local_interface_lists();
}
コード例 #12
0
ファイル: plug-edit.c プロジェクト: goedson/gnotime
static void
edit_plugin_delete_cb (GtkWidget * w, gpointer data)
{
	int row;
	GnomeUIInfo *sysmenus;
	PluginEditorDialog *dlg = data;

	if (FALSE == dlg->have_selection) return;

	/* Get selected item */
	row = edit_plugin_get_index_of_selected_item (dlg);
	if (-1 == row) return;

	/* DO NOT delete the end-of-array marker */
	sysmenus = (GnomeUIInfo *) dlg->menus->data;
	if (GNOME_APP_UI_ENDOFINFO == sysmenus[row].type) return;

	dlg->menus = g_array_remove_index (dlg->menus, row);
	/* XXX mem leak .. should delete ui item */

	/* Redraw the tree */
	edit_plugin_redraw_tree (dlg);

	/* Update selected row, as appropriate */
	dlg->have_selection = FALSE;
	edit_plugin_tree_selection_changed_cb (dlg->selection, dlg);
}
コード例 #13
0
static void
compare_garrays (void)
{
	GArray *array1;
	GArray *array2;
	GValue value1 = { 0 };
	GValue value2 = { 0 };
	int i;

	g_value_init (&value1, DBUS_TYPE_G_UINT_ARRAY);
	array1 = g_array_new (FALSE, FALSE, sizeof (guint32));

	g_value_init (&value2, DBUS_TYPE_G_UINT_ARRAY);
	array2 = g_array_new (FALSE, FALSE, sizeof (guint32));

	for (i = 0; i < 5; i++) {
		g_array_append_val (array1, i);
		g_array_append_val (array2, i);
	}

	g_value_set_boxed (&value1, array1);
	g_value_set_boxed (&value2, array2);

	g_print ("Comparing identical arrays's: %d\n", _gvalues_compare (&value1, &value2));

	g_array_remove_index (array2, 0);
	g_value_set_boxed (&value2, array2);
	g_print ("Comparing different length arrays's: %d\n", _gvalues_compare (&value1, &value2));

	i = 7;
	g_array_prepend_val (array2, i);
	g_value_set_boxed (&value2, array2);
	g_print ("Comparing different arrays's: %d\n", _gvalues_compare (&value1, &value2));
}
コード例 #14
0
/**
 * gst_rtsp_message_remove_header:
 * @msg: a #GstRTSPMessage
 * @field: a #GstRTSPHeaderField
 * @indx: the index of the header
 *
 * Remove the @indx header with key @field from @msg. If @indx equals -1, all
 * headers will be removed.
 *
 * Returns: a #GstRTSPResult.
 */
GstRTSPResult
gst_rtsp_message_remove_header (GstRTSPMessage * msg, GstRTSPHeaderField field,
    gint indx)
{
  GstRTSPResult res = GST_RTSP_ENOTIMPL;
  guint i = 0;
  gint cnt = 0;

  g_return_val_if_fail (msg != NULL, GST_RTSP_EINVAL);

  while (i < msg->hdr_fields->len) {
    RTSPKeyValue *key_value = &g_array_index (msg->hdr_fields, RTSPKeyValue, i);

    if (key_value->field == field && (indx == -1 || cnt++ == indx)) {
      g_free (key_value->value);
      g_array_remove_index (msg->hdr_fields, i);
      res = GST_RTSP_OK;
      if (indx != -1)
        break;
    } else {
      i++;
    }
  }
  return res;
}
コード例 #15
0
static void
nmt_editor_grid_remove (NmtNewtContainer *container,
                      NmtNewtWidget    *widget)
{
	NmtEditorGrid *grid = NMT_EDITOR_GRID (container);
	NmtEditorGridPrivate *priv = NMT_EDITOR_GRID_GET_PRIVATE (grid);
	NmtNewtContainerClass *parent_class = NMT_NEWT_CONTAINER_CLASS (nmt_editor_grid_parent_class);
	NmtEditorGridRow *rows = (NmtEditorGridRow *) priv->rows->data;
	int i;

	i = nmt_editor_grid_find_widget (grid, widget);
	if (i != -1) {
		if (rows[i].label)
			parent_class->remove (container, rows[i].label);
		parent_class->remove (container, rows[i].widget);
		if (rows[i].extra)
			parent_class->remove (container, rows[i].extra);

		g_array_remove_index (priv->rows, i);
		return;
	}

	// FIXME: shouldn't happen
	parent_class->remove (container, widget);
}
コード例 #16
0
ファイル: meta0_prefixassign.c プロジェクト: korween/oio-sds
static gboolean
_select_prefix(GArray *prefixes, guint8 *treat_prefixes)
{
	if (!prefixes) {
		return FALSE;
	}

	if ( prefixes->len != 0 ) {
		guint8 *prefix = (guint8 *)prefixes->data;
		if(!_is_treat_prefix(treat_prefixes,prefix)) {
			GRID_TRACE("select prefix %02X%02X ",prefix[0],prefix[1]);
			return TRUE;
		}

		prefixes=g_array_remove_index(prefixes,0);	

		if ( prefixes->len != 0 ) {
			return _select_prefix(prefixes,treat_prefixes);
		} 
	}

	g_array_free(prefixes,TRUE);
	prefixes=NULL;

	return FALSE;
}
コード例 #17
0
ファイル: capture_opts.c プロジェクト: huzhiren/wireshark
/*
 * Given a string of the form "<username>:<password>", as might appear
 * as an argument to a "-A" option, parse it and set the arguments in
 * question.  Return an indication of whether it succeeded or failed
 * in some fashion.
 */
static gboolean
get_auth_arguments(capture_options *capture_opts, const char *arg)
{
    gchar *p = NULL, *colonp;

    colonp = strchr(arg, ':');
    if (colonp == NULL)
        return FALSE;

    p = colonp;
    *p++ = '\0';

    while (isspace((guchar)*p))
        p++;

    if (capture_opts->ifaces->len > 0) {
        interface_options interface_opts;

        interface_opts = g_array_index(capture_opts->ifaces, interface_options, capture_opts->ifaces->len - 1);
        capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, capture_opts->ifaces->len - 1);
        interface_opts.auth_type = CAPTURE_AUTH_PWD;
        interface_opts.auth_username = g_strdup(arg);
        interface_opts.auth_password = g_strdup(p);
        g_array_append_val(capture_opts->ifaces, interface_opts);
    } else {
        capture_opts->default_options.auth_type = CAPTURE_AUTH_PWD;
        capture_opts->default_options.auth_username = g_strdup(arg);
        capture_opts->default_options.auth_password = g_strdup(p);
    }
    *colonp = ':';
    return TRUE;
}
コード例 #18
0
ファイル: misc2_callbacks.c プロジェクト: kashifsoofi/bygfoot
G_MODULE_EXPORT void
on_button_yesno_yes_clicked            (GtkButton       *button,
                                        gpointer         user_data)
{
#ifdef DEBUG
    printf("on_button_yesno_yes_clicked\n");
#endif

     
    window_destroy(&window.yesno);
    setsav0;

    switch(stat1)
    {
    default:
        debug_print_message("on_button_yesno_yes_clicked: unknown status %d\n", stat1);
        break;
    case STATUS_PAY_LOAN:
        on_automatic_loan_repayment_activate(NULL, NULL);
        break;
    case STATUS_FIRE_PLAYER:
        player_remove_from_team(current_user.tm, stat2);
        current_user.money -= stat3;
        current_user.money_out[1][MON_OUT_COMPENSATIONS] -= stat3;
        treeview_show_user_player_list();
        game_gui_set_main_window_header();
        break;
    case STATUS_USER_MANAGEMENT:
        user_remove(stat2, TRUE);
        treeview_show_users(
            GTK_TREE_VIEW(lookup_widget(window.user_management,
                                        "treeview_user_management_users")));
        treeview_show_team_list(
            GTK_TREE_VIEW(lookup_widget(window.user_management, 
                                        "treeview_user_management_teams")),
            FALSE, FALSE);
        break;
    case STATUS_QUERY_UNFIT:
        load_save_autosave();
        callback_show_next_live_game();
        break;
    case STATUS_QUERY_QUIT:
        main_exit_program(EXIT_OK, NULL);
        break;
    case STATUS_QUERY_USER_NO_TURN:
        load_save_autosave();
        callback_show_next_live_game();
        break;
    case STATUS_QUERY_KICK_YOUTH:
        free_player(&g_array_index(current_user.youth_academy.players, Player, selected_row));
        g_array_remove_index(current_user.youth_academy.players, selected_row);
        on_menu_show_youth_academy_activate(NULL, NULL);
        selected_row = -1;
        break;
    }

    if(stat4 == STATUS_SHOW_EVENT)
	user_event_show_next();
}
コード例 #19
0
static void
gimp_motion_buffer_pop_event_queue (GimpMotionBuffer *buffer,
                                    GimpCoords       *coords)
{
  *coords = g_array_index (buffer->event_queue, GimpCoords, 0);

  g_array_remove_index (buffer->event_queue, 0);
}
コード例 #20
0
static void
gimp_motion_buffer_push_event_history (GimpMotionBuffer *buffer,
                                       const GimpCoords *coords)
{
  if (buffer->event_history->len == 4)
    g_array_remove_index (buffer->event_history, 0);

  g_array_append_val (buffer->event_history, *coords);
}
コード例 #21
0
static void
set_rdnss_timeout (NMIP6Device *device)
{
	time_t expires = 0, now = time (NULL);
	NMIP6RDNSS *rdnss;
	int i;

	if (device->rdnss_timeout_id) {
		g_source_remove (device->rdnss_timeout_id);
		device->rdnss_timeout_id = 0;
	}

	/* Find the soonest expiration time. */
	for (i = 0; i < device->rdnss_servers->len; i++) {
		rdnss = &g_array_index (device->rdnss_servers, NMIP6RDNSS, i);
		if (rdnss->expires == 0)
			continue;

		/* If the entry has already expired, remove it; the "+ 1" is
		 * because g_timeout_add_seconds() might fudge the timing a
		 * bit.
		 */
		if (rdnss->expires <= now + 1) {
			char buf[INET6_ADDRSTRLEN + 1];

			if (inet_ntop (AF_INET6, &(rdnss->addr), buf, sizeof (buf)) > 0) {
				nm_log_dbg (LOGD_IP6, "(%s): removing expired RA-provided nameserver %s",
				            device->iface, buf);
			}
			g_array_remove_index (device->rdnss_servers, i--);
			continue;
		}

		if (!expires || rdnss->expires < expires)
			expires = rdnss->expires;
	}

	if (expires) {
		gchar *msg;

		device->rdnss_timeout = MIN (expires - now, G_MAXUINT32 - 1);

		if (device->rdnss_timeout <= 5) {
			msg = g_strdup_printf ("IPv6 RDNSS about to expire in %d seconds",
			                       device->rdnss_timeout);
			device_send_router_solicitation (device, msg);
			g_free (msg);
			device->rdnss_timeout_id = g_timeout_add_seconds (device->rdnss_timeout,
			                                                  rdnss_expired,
			                                                  device);
		} else {
			device->rdnss_timeout_id = g_timeout_add_seconds (device->rdnss_timeout / 2,
			                                                  rdnss_needs_refresh,
			                                                  device);
		}
	}
}
コード例 #22
0
void
summary_fill_in_capture(capture_file *cf,capture_options *capture_opts, summary_tally *st)
{
  iface_options iface;
  interface_t device;
  guint i;
  wtapng_iface_descriptions_t* idb_info;
  wtapng_if_descr_t wtapng_if_descr;
  wtapng_if_stats_t *if_stats;

  while (st->ifaces->len > 0) {
    iface = g_array_index(st->ifaces, iface_options, 0);
    st->ifaces = g_array_remove_index(st->ifaces, 0);
    g_free(iface.name);
    g_free(iface.descr);
    g_free(iface.cfilter);
  }
  if (st->is_tempfile) {
    for (i = 0; i < capture_opts->all_ifaces->len; i++) {
      device = g_array_index(capture_opts->all_ifaces, interface_t, i);
      if (!device.selected) {
        continue;
      }
      iface.cfilter = g_strdup(device.cfilter);
      iface.name = g_strdup(device.name);
      iface.descr = g_strdup(device.display_name);
      iface.drops_known = cf->drops_known;
      iface.drops = cf->drops;
      iface.has_snap = device.has_snaplen;
      iface.snap = device.snaplen;
      iface.linktype = device.active_dlt;
      g_array_append_val(st->ifaces, iface);
    }
  } else {
    idb_info = wtap_file_get_idb_info(cf->wth);
    for (i = 0; i < idb_info->number_of_interfaces; i++) {
      wtapng_if_descr = g_array_index(idb_info->interface_data, wtapng_if_descr_t, i);
      iface.cfilter = g_strdup(wtapng_if_descr.if_filter_str);
      iface.name = g_strdup(wtapng_if_descr.if_name);
      iface.descr = g_strdup(wtapng_if_descr.if_description);
      iface.drops_known = FALSE;
      iface.drops = 0;
      iface.snap = wtapng_if_descr.snap_len;
      iface.has_snap = (iface.snap != 65535);
      iface.linktype = wtapng_if_descr.link_type;
	  if(wtapng_if_descr.num_stat_entries == 1){
		  /* dumpcap only writes one ISB, only handle that for now */
		  if_stats = &g_array_index(wtapng_if_descr.interface_statistics, wtapng_if_stats_t, 0);
		  iface.drops_known = TRUE;
		  iface.drops = if_stats->isb_ifdrop;
		  iface.isb_comment = if_stats->opt_comment;
	  }
      g_array_append_val(st->ifaces, iface);
    }
    g_free(idb_info);
  }
}
コード例 #23
0
ファイル: parent.c プロジェクト: nehaahir/wireshark
/* stop it */
static echld_state_t msgh_detach(echld_t* c, int msgh_id) {
	int idx = msgh_idx(c,msgh_id);

	if (idx < 0) return -1;

	g_array_remove_index(c->handlers,idx);

	return 1;
}
コード例 #24
0
ファイル: gwyinventory.c プロジェクト: svn2github/gwyddion
/**
 * gwy_inventory_delete_nth_item_real:
 * @inventory: An inventory.
 * @name: Item name (to avoid double lookups from gwy_inventory_delete_item()).
 * @i: Storage position of item to remove.
 *
 * Removes an item from an inventory given its physical position.
 *
 * A kind of g_array_remove_index_fast(), but updating references.
 **/
static void
gwy_inventory_delete_nth_item_real(GwyInventory *inventory,
                                   const gchar *name,
                                   guint i)
{
    gpointer mp, lp;
    guint n, last;
    gboolean emit_change = FALSE;

    mp = g_ptr_array_index(inventory->items, i);
    if (inventory->item_type.is_fixed
        && inventory->item_type.is_fixed(mp)) {
        g_warning("Cannot delete fixed item `%s'", name);
        return;
    }
    if (inventory->has_default
        && gwy_strequal(name, inventory->default_key->str))
        emit_change = TRUE;

    if (inventory->is_watchable)
        gwy_inventory_disconnect_from_item(mp, inventory);

    if (inventory->needs_reindex)
        gwy_inventory_reindex(inventory);

    if (inventory->item_type.dismantle)
        inventory->item_type.dismantle(mp);

    n = g_array_index(inventory->idx, guint, i);
    last = inventory->items->len - 1;

    /* Move last item of @items to position of removed item */
    if (inventory->hash)
        g_hash_table_remove(inventory->hash, name);
    if (i < last) {
        lp = g_ptr_array_index(inventory->items, last);
        g_ptr_array_index(inventory->items, i) = lp;
        name = inventory->item_type.get_name(lp);
        if (inventory->hash)
            g_hash_table_insert(inventory->hash, (gpointer)name,
                                GUINT_TO_POINTER(i+1));
        g_array_index(inventory->ridx, guint,
                      g_array_index(inventory->idx, guint, last)) = i;
    }
    g_array_remove_index(inventory->ridx, n);
    g_ptr_array_set_size(inventory->items, last);
    g_array_set_size(inventory->idx, last);
    inventory->needs_reindex = TRUE;

    if (inventory->is_object)
        g_object_unref(mp);

    g_signal_emit(inventory, gwy_inventory_signals[ITEM_DELETED], 0, n);
    if (emit_change)
        g_signal_emit(inventory, gwy_inventory_signals[DEFAULT_CHANGED], 0);
}
コード例 #25
0
//********************************my_atk_text_remove_selection*******************************
gboolean my_atk_text_remove_selection(AtkText *text, gint selection_num)
{
    MyAtkText *self = (MyAtkText*)text;
    GArray *selections = self->selections;
    if(selection_num < 0 || selection_num >= selections->len) return FALSE;
    g_array_remove_index(selections, selection_num);
    
    g_signal_emit_by_name(text, "text-selection-changed");
    return TRUE;
}
コード例 #26
0
static void
gesture_unregister_point (ClutterGestureAction *action, gint position)
{
  ClutterGestureActionPrivate *priv = action->priv;

  if (action->priv->points->len == 0)
    return;

  g_array_remove_index (priv->points, position);
}
コード例 #27
0
ファイル: values.c プロジェクト: 273657127/HandBrake
void
ghb_array_remove(GValue *gval, guint ii)
{
	GArray *arr = g_value_get_boxed(gval);
	// A little nastyness here.  The array pointer
	// can change when the array changes size.  So
	// I must re-box it in the GValue each time.
	arr = g_array_remove_index(arr, ii);
	memset(gval, 0, sizeof(GValue));
	g_value_init(gval, ghb_array_get_type());
	g_value_take_boxed(gval, arr);
}
コード例 #28
0
/**
 * nm_setting_ip4_config_remove_dns:
 * @setting: the #NMSettingIP4Config
 * @i: index number of the DNS server to remove
 *
 * Removes the DNS server at index @i.
 **/
void
nm_setting_ip4_config_remove_dns (NMSettingIP4Config *setting, guint32 i)
{
	NMSettingIP4ConfigPrivate *priv;

	g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));

	priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
	g_return_if_fail (i <= priv->dns->len);

	g_array_remove_index (priv->dns, i);
}
コード例 #29
0
ファイル: keybindings.c プロジェクト: Ygrex/termit
void termit_keys_unbind(const gchar* keybinding)
{
    gint kb_index = get_kb_index(keybinding);
    if (kb_index < 0) {
        TRACE("keybinding [%s] not found - skipping", keybinding);
        return;
    }
    struct KeyBinding* kb = &g_array_index(configs.key_bindings, struct KeyBinding, kb_index);
    termit_lua_unref(&kb->lua_callback);
    g_free(kb->name);
    g_array_remove_index(configs.key_bindings, kb_index);
}
コード例 #30
0
static void
set_dnssl_timeout (NMIP6Device *device)
{
	time_t expires = 0, now = time (NULL);
	NMIP6DNSSL *dnssl;
	int i;

	if (device->dnssl_timeout_id) {
		g_source_remove (device->dnssl_timeout_id);
		device->dnssl_timeout_id = 0;
	}

	/* Find the soonest expiration time. */
	for (i = 0; i < device->dnssl_domains->len; i++) {
		dnssl = &g_array_index (device->dnssl_domains, NMIP6DNSSL, i);
		if (dnssl->expires == 0)
			continue;

		/* If the entry has already expired, remove it; the "+ 1" is
		 * because g_timeout_add_seconds() might fudge the timing a
		 * bit.
		 */
		if (dnssl->expires <= now + 1) {
			nm_log_dbg (LOGD_IP6, "(%s): removing expired RA-provided domain %s",
			            device->iface, dnssl->domain);
			g_array_remove_index (device->dnssl_domains, i--);
			continue;
		}

		if (!expires || dnssl->expires < expires)
			expires = dnssl->expires;
	}

	if (expires) {
		gchar *msg;

		device->dnssl_timeout = MIN (expires - now, G_MAXUINT32 - 1);

		if (device->dnssl_timeout <= 5) {
			msg = g_strdup_printf ("IPv6 DNSSL about to expire in %d seconds",
			                       device->dnssl_timeout);
			device_send_router_solicitation (device, msg);
			g_free (msg);
			device->dnssl_timeout_id = g_timeout_add_seconds (device->dnssl_timeout,
			                                                  dnssl_expired,
			                                                  device);
		} else {
			device->dnssl_timeout_id = g_timeout_add_seconds (device->dnssl_timeout / 2,
			                                                  dnssl_needs_refresh,
			                                                  device);
		}
	}
}