void CaptureInterfacesDialog::tableItemClicked(QTableWidgetItem * item) { Q_UNUSED(item) interface_t device; global_capture_opts.num_selected = 0; for (int row = 0; row < ui->tbInterfaces->rowCount(); row++) { bool checked = (ui->tbInterfaces->item(row, 0)->checkState() == Qt::Checked) ? true : false; QString interface_name = ui->tbInterfaces->item(row, 1)->text(); device = g_array_index(global_capture_opts.all_ifaces, interface_t, row); if (checked == true) { device.selected = TRUE; global_capture_opts.num_selected++; global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, row); g_array_insert_val(global_capture_opts.all_ifaces, row, device); } else { device.selected = FALSE; global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, row); g_array_insert_val(global_capture_opts.all_ifaces, row, device); } } }
static void store_selected(GtkWidget *choose_bt, gpointer name) { interface_t device; guint i; for (i = 0; i < global_capture_opts.all_ifaces->len; i++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); if (strcmp((char *)name, device.if_info.name) == 0) { if (!device.locked) { device.selected ^= 1; if (device.selected) { global_capture_opts.num_selected++; } else { global_capture_opts.num_selected--; } 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); if (gtk_widget_is_focus(choose_bt) && get_welcome_window()) { change_interface_selection(device.name, device.selected); } if (gtk_widget_is_focus(choose_bt) && capture_dlg_window_present()) { enable_selected_interface(device.name, device.selected); } device.locked = 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); } break; } } if (cap_if_w) { gtk_widget_set_sensitive(capture_bt, !gbl_capture_in_progress && (global_capture_opts.num_selected > 0)); } }
void InterfaceTree::updateSelectedInterfaces() { QTreeWidgetItemIterator iter(this); global_capture_opts.num_selected = 0; while (*iter) { for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { QString device_name = (*iter)->data(0, Qt::UserRole).value<QString>(); interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); if (device_name.compare(QString().fromUtf8(device.name)) == 0) { if (!device.locked) { if ((*iter)->isSelected()) { device.selected = TRUE; global_capture_opts.num_selected++; } else { device.selected = FALSE; } device.locked = TRUE; 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); emit interfaceUpdated(device.name, device.selected); device.locked = 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); } break; } } iter++; } }
static void extend_times (StreamInfo * si, GstClockTime start, GstClockTime end) { PlayState *state = si->state; StreamTSRange *ts = NULL; StreamTSRange tsn; GArray *a; guint i, n; /* Set up new entry, in case we need it */ tsn.start = start; tsn.end = end; if (state->fwd_play) { a = si->fwd_times; n = a->len; /* if playing forward, see if this new time extends the last entry */ i = n - 1; } else { a = si->bkwd_times; n = a->len; /* if playing backward, see if this new time extends the earliest entry */ i = 0; } if (n > 0) { ts = &g_array_index (a, StreamTSRange, i); if (start > ts->start) { /* This entry is after the most recent entry */ /* Tolerance of 1 millisecond allowed for imprecision */ if (ts->end + GST_MSECOND >= start) { GST_LOG ("%p extending entry %d to %" GST_TIME_FORMAT, si, i, GST_TIME_ARGS (end)); ts->end = end; return; } /* new start > ts->end, so this new entry goes after the first one */ GST_LOG ("%p inserting new entry %d %" GST_TIME_FORMAT " to %" GST_TIME_FORMAT, si, i + 1, GST_TIME_ARGS (start), GST_TIME_ARGS (end)); g_array_insert_val (a, i + 1, tsn); return; } else if (end + GST_MSECOND > ts->start) { /* This entry precedes the current one, but overlaps it */ GST_LOG ("%p pre-extending entry %d to %" GST_TIME_FORMAT, si, i, GST_TIME_ARGS (start)); ts->start = start; return; } } else { i = 0; } /* otherwise insert a new entry before/at the start */ GST_LOG ("%p New entry %d - %" GST_TIME_FORMAT " to %" GST_TIME_FORMAT, si, i, GST_TIME_ARGS (start), GST_TIME_ARGS (end)); g_array_insert_val (a, i, tsn); }
static gint update_active_playlist (xmmsv_t *val, void *udata) { cli_infos_t *infos = (cli_infos_t *) udata; cli_cache_t *cache = infos->cache; xmmsc_result_t *refres; gint pos, newpos, type; gint id; const gchar *name; xmmsv_dict_entry_get_int (val, "type", &type); xmmsv_dict_entry_get_int (val, "position", &pos); xmmsv_dict_entry_get_int (val, "id", &id); xmmsv_dict_entry_get_string (val, "name", &name); /* Active playlist not changed, nevermind */ if (strcmp (name, cache->active_playlist_name) != 0) { return TRUE; } /* Apply changes to the cached playlist */ switch (type) { case XMMS_PLAYLIST_CHANGED_ADD: g_array_append_val (cache->active_playlist, id); break; case XMMS_PLAYLIST_CHANGED_INSERT: g_array_insert_val (cache->active_playlist, pos, id); break; case XMMS_PLAYLIST_CHANGED_MOVE: xmmsv_dict_entry_get_int (val, "newposition", &newpos); g_array_remove_index (cache->active_playlist, pos); g_array_insert_val (cache->active_playlist, newpos, id); break; case XMMS_PLAYLIST_CHANGED_REMOVE: g_array_remove_index (cache->active_playlist, pos); break; case XMMS_PLAYLIST_CHANGED_SHUFFLE: case XMMS_PLAYLIST_CHANGED_SORT: case XMMS_PLAYLIST_CHANGED_CLEAR: /* Oops, reload the whole playlist */ refres = xmmsc_playlist_list_entries (infos->conn, XMMS_ACTIVE_PLAYLIST); xmmsc_result_notifier_set (refres, &refresh_active_playlist, infos->cache); xmmsc_result_unref (refres); freshness_requested (&cache->freshness_active_playlist); break; } return TRUE; }
static void edit_plugin_add_cb (GtkWidget * w, gpointer data) { PluginEditorDialog *dlg = data; GnomeUIInfo item, *uientry; GtkTreeIter iter; int index; GttPlugin *plg; /* Create a plugin, copy widget values into it. */ plg = gtt_plugin_new ("x", "/x"); if (!plg) return; item.user_data = plg; edit_plugin_widgets_to_item (dlg, &item); /* Insert item into list, or, if no selection, append */ index = edit_plugin_get_index_of_selected_item (dlg); if (0 > index) index = dlg->menus->len -1; g_array_insert_val (dlg->menus, index, item); /* Redraw the tree */ edit_plugin_redraw_tree (dlg); /* Select the new row. Not strictly needed, unless there * had not been any selection previously. */ uientry = (GnomeUIInfo *) dlg->menus->data; edit_plugin_get_iter_of_item (dlg, &uientry[index], &iter); gtk_tree_selection_select_iter (dlg->selection, &iter); }
static void wtap_opttype_block_register(wtap_block_type_t block_type, wtap_blocktype_t *blocktype) { static const wtap_opttype_t opt_comment = { "opt_comment", "Comment", WTAP_OPTTYPE_STRING, WTAP_OPTTYPE_FLAG_MULTIPLE_ALLOWED, NULL, NULL }; /* Check input */ g_assert(block_type < WTAP_BLOCK_END_OF_LIST); /* Don't re-register. */ g_assert(blocktype_list[block_type] == NULL); /* Sanity check */ g_assert(blocktype->name); g_assert(blocktype->description); g_assert(blocktype->create); blocktype->block_type = block_type; /* * Initialize the set of supported options. * All blocks that support options at all support OPT_COMMENT. */ blocktype->options = g_array_sized_new(FALSE, TRUE, sizeof (wtap_opttype_t), OPT_COMMENT + 1); if (OPT_COMMENT + 1 > blocktype->options->len) g_array_set_size(blocktype->options, OPT_COMMENT + 1); g_array_insert_val(blocktype->options, OPT_COMMENT, opt_comment); blocktype_list[block_type] = blocktype; }
/** * gdl_dock_object_set_type_for_nick: * @nick: The nickname for the object type * @type: The object type * * Assigns an object type to a given nickname. If the nickname already exists, * then it reassigns it to a new object type. * * Returns: If the nick was previously assigned, the old type is returned. * Otherwise, %G_TYPE_NONE. */ GType gdl_dock_object_set_type_for_nick (const gchar *nick, GType type) { GType old_type = G_TYPE_NONE; guint i = 0; struct DockRegisterItem new_item; new_item.nick = g_strdup(nick); new_item.type = (gpointer) type; if (!dock_register) gdl_dock_object_register_init (); g_return_val_if_fail (g_type_is_a (type, GDL_TYPE_DOCK_OBJECT), G_TYPE_NONE); for (i = 0; i < dock_register->len; i++) { struct DockRegisterItem item = g_array_index (dock_register, struct DockRegisterItem, i); if (!g_strcmp0 (nick, item.nick)) { old_type = (GType) item.type; g_array_insert_val (dock_register, i, new_item); } } return old_type; }
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); } }
static void mex_music_player_shuffle_toggled (MexMusicPlayer *player, GParamSpec *spec, MxButton *button) { MexMusicPlayerPrivate *priv = player->priv; gint i; if (mx_button_get_toggled (button)) { gint length; length = mex_model_get_length (priv->model); priv->shuffle = g_array_sized_new (FALSE, FALSE, sizeof (gint), length); for (i = 0; i < length; i++) g_array_insert_val (priv->shuffle, i, i); /* shuffle the list */ g_array_sort (priv->shuffle, mex_music_player_random_sort); } else { if (priv->shuffle) { g_array_free (priv->shuffle, TRUE); priv->shuffle = NULL; } } }
static void on_insert (void) { GtkTreeIter iter; int insert_pos; char new_value[2]; new_value[0] = next_value++; new_value[1] = '\0'; if (next_value > 'Z') next_value = 'A'; if (contents->len) insert_pos = g_random_int_range (0, contents->len + 1); else insert_pos = 0; gtk_list_store_insert (model, &iter, insert_pos); gtk_list_store_set (model, &iter, 0, new_value, -1); g_array_insert_val (contents, insert_pos, new_value); combochange_log ("Inserted '%c' at position %d", new_value[0], insert_pos); }
void _gtk_style_cascade_add_provider (GtkStyleCascade *cascade, GtkStyleProvider *provider, guint priority) { GtkStyleProviderData data; guint i; g_return_if_fail (GTK_IS_STYLE_CASCADE (cascade)); g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider)); g_return_if_fail (GTK_STYLE_PROVIDER (cascade) != provider); data.provider = g_object_ref (provider); data.priority = priority; data.changed_signal_id = g_signal_connect_swapped (provider, "-gtk-private-changed", G_CALLBACK (_gtk_style_provider_private_changed), cascade); /* ensure it gets removed first */ _gtk_style_cascade_remove_provider (cascade, provider); for (i = 0; i < cascade->providers->len; i++) { if (g_array_index (cascade->providers, GtkStyleProviderData, i).priority > priority) break; } g_array_insert_val (cascade->providers, i, data); _gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (cascade)); }
//********************************my_atk_text_add_selection******************************* gboolean my_atk_text_add_selection(AtkText *text, gint start_offset, gint end_offset) { if(start_offset < 0 || end_offset > my_atk_text_get_character_count(text) || start_offset >= end_offset) return FALSE; MyAtkText *self = (MyAtkText*)text; GArray *selections = self->selections; gint i; for(i = 0; i < selections->len; i++) { if(g_array_index(selections, TextSelection, i).start_offset >= start_offset) { if(g_array_index(selections, TextSelection, i).start_offset < end_offset) return FALSE; break; } } TextSelection new_selection; new_selection.start_offset = start_offset; new_selection.end_offset = end_offset; g_array_insert_val(selections, i, new_selection); g_signal_emit_by_name(text, "text-selection-changed"); return TRUE; }
void new_stat_tap_add_table(new_stat_tap_ui* new_stat, new_stat_tap_table* table) { if (new_stat->tables == NULL) new_stat->tables = g_array_new(FALSE, TRUE, sizeof(new_stat_tap_table*)); g_array_insert_val(new_stat->tables, new_stat->tables->len, table); }
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); device.display_name = get_iface_display_name(comment.toUtf8().constData(), &device.if_info); 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); } }
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); } }
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); } }
/** * gwy_inventory_insert_nth_item: * @inventory: An inventory. * @item: An item to insert. * @n: Position to insert @item to. * * Inserts an item to an explicit position in an inventory. * * Item of the same name must not exist yet. * * Returns: @item, for convenience. **/ gpointer gwy_inventory_insert_nth_item(GwyInventory *inventory, gpointer item, guint n) { const gchar *name; g_return_val_if_fail(GWY_IS_INVENTORY(inventory), NULL); g_return_val_if_fail(!inventory->is_const, NULL); g_return_val_if_fail(item, NULL); g_return_val_if_fail(n <= inventory->items->len, NULL); name = inventory->item_type.get_name(item); if (gwy_inventory_lookup(inventory, name)) { g_warning("Item `%s' already exists", name); return NULL; } if (inventory->is_object) g_object_ref(item); g_array_insert_val(inventory->ridx, n, inventory->items->len); inventory->needs_reindex = TRUE; g_array_append_val(inventory->idx, n); /* value does not matter */ g_ptr_array_add(inventory->items, item); g_hash_table_insert(inventory->hash, (gpointer)name, GUINT_TO_POINTER(inventory->items->len)); if (inventory->is_sorted) { gpointer mp; if (n > 0) { mp = g_ptr_array_index(inventory->items, g_array_index(inventory->ridx, guint, n-1)); if (inventory->item_type.compare(item, mp) < 0) inventory->is_sorted = FALSE; } if (inventory->is_sorted && n+1 < inventory->items->len) { mp = g_ptr_array_index(inventory->items, g_array_index(inventory->ridx, guint, n+1)); if (inventory->item_type.compare(item, mp) > 0) inventory->is_sorted = FALSE; } } if (inventory->is_watchable) gwy_inventory_connect_to_item(item, inventory); g_signal_emit(inventory, gwy_inventory_signals[ITEM_INSERTED], 0, n); if (inventory->has_default && gwy_strequal(name, inventory->default_key->str)) g_signal_emit(inventory, gwy_inventory_signals[DEFAULT_CHANGED], 0); return item; }
void ghb_array_insert(GValue *gval, guint ii, GValue *val) { 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_insert_val(arr, ii, val); memset(gval, 0, sizeof(GValue)); g_value_init(gval, ghb_array_get_type()); g_value_take_boxed(gval, arr); }
void InterfaceTree::setSelectedInterfaces() { #ifdef HAVE_LIBPCAP interface_t device; QTreeWidgetItemIterator iter(this); while (*iter) { QString device_name = (*iter)->data(IFTREE_COL_NAME, Qt::UserRole).value<QString>(); for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); if (device_name.compare(QString().fromUtf8(device.name)) == 0) { (*iter)->setSelected(device.selected); 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); break; } 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); } iter++; } #endif // HAVE_LIBPCAP }
void CaptureInterfacesDialog::on_capturePromModeCheckBox_toggled(bool checked) { interface_t device; prefs.capture_prom_mode = checked; for (int row = 0; row < ui->tbInterfaces->rowCount(); row++){ device = g_array_index(global_capture_opts.all_ifaces, interface_t, deviceMap[row]); QString device_name = ui->tbInterfaces->item(row, INTERFACE)->text(); device.pmode = checked; global_capture_opts.all_ifaces = g_array_remove_index(global_capture_opts.all_ifaces, deviceMap[row]); g_array_insert_val(global_capture_opts.all_ifaces, deviceMap[row], device); QTableWidgetItem *it = ui->tbInterfaces->item(row, PMODE); it->setText(checked? tr("enabled"):tr("disabled")); } }
static GArray* Wordlist_selectedToBitmapArray( GArray* a ) { GArray* ret = g_array_new( 1, 1, sizeof(gint) ); ret = g_array_set_size( ret, PATH_MAX+1 ); int i = 0; for (i = 0; i < a->len; i++) { int v = g_array_index (a, gint, i); int one = 1; g_array_insert_val( ret, v, one ); } return ret; }
void CaptureFilterEdit::setFilterSyntaxState(QString filter, bool valid, QString err_msg) { if (filter.compare(text()) == 0) { // The user hasn't changed the filter if (valid) { setSyntaxState(text().isEmpty() ? Empty : Valid); } else { setSyntaxState(Invalid); emit pushFilterSyntaxStatus(err_msg); } } #ifdef HAVE_LIBPCAP if (syntaxState() != Invalid) { if (bookmark_button_) { bookmark_button_->setEnabled(true); } if (apply_button_) { apply_button_->setEnabled(true); } valid = true; g_free(global_capture_opts.default_options.cfilter); if (filter.isEmpty()) { global_capture_opts.default_options.cfilter = NULL; } else { global_capture_opts.default_options.cfilter = qstring_strdup(filter); } if (global_capture_opts.num_selected > 0) { interface_t device; for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); if (!device.selected) { continue; } // if (device.active_dlt == -1) { // simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "The link type of interface %s was not specified.", device.name); // continue; /* Programming error: somehow managed to select an "unsupported" entry */ // } g_array_remove_index(global_capture_opts.all_ifaces, i); device.cfilter = qstring_strdup(filter); g_array_insert_val(global_capture_opts.all_ifaces, i, device); // update_filter_string(device.name, filter_text); } } } #endif // HAVE_LIBPCAP emit captureFilterSyntaxChanged(valid); }
/* makes a copy of a aosd_cfg_osd_t object (mostly used by aosd_display) */ aosd_cfg_osd_t * aosd_cfg_osd_copy ( aosd_cfg_osd_t * cfg_osd ) { aosd_cfg_osd_t *cfg_osd_copy = aosd_cfg_osd_new(); gint i = 0; /* copy information */ cfg_osd_copy->position.placement = cfg_osd->position.placement; cfg_osd_copy->position.offset_x = cfg_osd->position.offset_x; cfg_osd_copy->position.offset_y = cfg_osd->position.offset_y; cfg_osd_copy->position.maxsize_width = cfg_osd->position.maxsize_width; cfg_osd_copy->position.multimon_id = cfg_osd->position.multimon_id; cfg_osd_copy->animation.timing_display = cfg_osd->animation.timing_display; cfg_osd_copy->animation.timing_fadein = cfg_osd->animation.timing_fadein; cfg_osd_copy->animation.timing_fadeout = cfg_osd->animation.timing_fadeout; for ( i = 0 ; i < AOSD_TEXT_FONTS_NUM ; i++ ) { cfg_osd_copy->text.fonts_name[i] = g_strdup( cfg_osd->text.fonts_name[i] ); cfg_osd_copy->text.fonts_color[i] = cfg_osd->text.fonts_color[i]; cfg_osd_copy->text.fonts_draw_shadow[i] = cfg_osd->text.fonts_draw_shadow[i]; cfg_osd_copy->text.fonts_shadow_color[i] = cfg_osd->text.fonts_shadow_color[i]; } cfg_osd_copy->text.utf8conv_disable = cfg_osd->text.utf8conv_disable; cfg_osd_copy->decoration.code = cfg_osd->decoration.code; cfg_osd_copy->decoration.skin_file = g_strdup( cfg_osd->decoration.skin_file ); for ( i = 0 ; i < cfg_osd->decoration.colors->len ; i++ ) { aosd_color_t color = g_array_index( cfg_osd->decoration.colors , aosd_color_t , i ); g_array_insert_val( cfg_osd_copy->decoration.colors , i , color ); } for ( i = 0 ; i < cfg_osd->trigger.active->len ; i++ ) { gint trigger_id = g_array_index( cfg_osd->trigger.active , gint , i ); g_array_insert_val( cfg_osd_copy->trigger.active , i , trigger_id ); } cfg_osd_copy->misc.transparency_mode = cfg_osd->misc.transparency_mode; return cfg_osd_copy; }
int main(void) { GArray *a = g_array_new(FALSE, FALSE, sizeof(int)); int x[2] = { 1, 5 }; g_array_append_vals(a, &x, 2); print_array(a); printf("Insert '2'\n"); int b = 2; g_array_insert_val(a, 1, b); print_array(a); printf("Inserting multiple values\n"); int y[2] = { 3, 4 }; g_array_insert_vals(a, 2, y, 2); print_array(a); g_array_free(a, FALSE); }
void CaptureInterfacesDialog::tableSelected() { interface_t device; if (!ui->tbInterfaces->selectedItems().size()) { for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); device.selected = false; device.locked = true; 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); } global_capture_opts.num_selected = 0; start_bt_->setEnabled(false); emit setSelectedInterfaces(); for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); device.locked = 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); } } updateWidgets(); }
// We don't actually store these. When we do we should make sure they're stored // securely using CryptProtectData, the OS X Keychain, GNOME Keyring, KWallet, etc. void ManageInterfacesDialog::remoteAccepted() { QTreeWidgetItemIterator it(ui->remoteList); while(*it) { for (guint i = 0; i < global_capture_opts.all_ifaces->len; i++) { interface_t device = g_array_index(global_capture_opts.all_ifaces, interface_t, i); if ((*it)->text(col_r_host_dev_).compare(device.name)) continue; device.hidden = ((*it)->checkState(col_r_show_) == Qt::Checked ? false : true); 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); } ++it; } }
/* Return interface_opts->descr (after setting it if it is not set) * This is necessary because capture_opts.c can't set descr (at least * not without adding significant dependencies there). */ const char * get_iface_description_for_interface(capture_options *capture_opts, guint i) { interface_options interface_opts; if (i < capture_opts->ifaces->len) { interface_opts = g_array_index(capture_opts->ifaces, interface_options, i); if (!interface_opts.descr && interface_opts.name) { interface_opts.descr = get_interface_descriptive_name(interface_opts.name); capture_opts->ifaces = g_array_remove_index(capture_opts->ifaces, i); g_array_insert_val(capture_opts->ifaces, i, interface_opts); } return (interface_opts.descr); } else { return (NULL); } }
/** * e2k_freebusy_add_interval: * @fb: an #E2kFreebusy * @busystatus: the busy status of the interval * @start: the start of the interval * @end: the end of the interval * * This adds an interval of type @busystatus to @fb. **/ void e2k_freebusy_add_interval (E2kFreebusy *fb, E2kBusyStatus busystatus, time_t start, time_t end) { E2kFreebusyEvent evt, *events; int i; if (busystatus == E2K_BUSYSTATUS_FREE) return; /* Clip to the fb's range */ if (start < fb->start) start = fb->start; if (end > fb->end) end = fb->end; if (end <= start) return; events = (E2kFreebusyEvent *)(fb->events[busystatus]->data); for (i = 0; i < fb->events[busystatus]->len; i++) { if (events[i].end >= start) break; } evt.start = start; evt.end = end; if (i == fb->events[busystatus]->len) g_array_append_val (fb->events[busystatus], evt); else { /* events[i] is the first event that is not completely * before evt, meaning it is either completely after it, * or they overlap/abut. */ if (events[i].start > end) { /* No overlap. Insert evt before events[i]. */ g_array_insert_val (fb->events[busystatus], i, evt); } else { /* They overlap or abut. Merge them. */ events[i].start = MIN (events[i].start, start); events[i].end = MAX (events[i].end, end); } } }
/* Add an icon to the list of current icons in a BalsaToolbarModel. */ void balsa_toolbar_model_insert_icon(BalsaToolbarModel * model, gchar * icon, gint position) { const gchar *real_button = balsa_toolbar_sanitize_id(icon); if (real_button) { BalsaToolbarEntry entry; entry.action = g_strdup(g_hash_table_lookup(model->legal, real_button)); entry.icon = g_strdup(real_button); if (position >= 0) g_array_insert_val(model->current, position, entry); else g_array_append_val(model->current, entry); } else g_warning(_("Unknown toolbar icon “%s”"), icon); }