/** * bastile_keyserver_sync_show * @keys: The keys to synchronize * * Shows a synchronize window. * * Returns the new window. **/ GtkWindow* bastile_keyserver_sync_show (GList *keys, GtkWindow *parent) { BastileWidget *swidget; GtkWindow *win; GtkWidget *w; guint n, notify_id; gchar *t; swidget = bastile_widget_new_allow_multiple ("keyserver-sync", parent); g_return_val_if_fail (swidget != NULL, NULL); win = GTK_WINDOW (bastile_widget_get_widget (swidget, swidget->name)); /* The details message */ n = g_list_length (keys); t = g_strdup_printf (ngettext ("<b>%d key is selected for synchronizing</b>", "<b>%d keys are selected for synchronizing</b>", n), n); w = GTK_WIDGET (bastile_widget_get_widget (swidget, "detail-message")); g_return_val_if_fail (swidget != NULL, win); gtk_label_set_markup (GTK_LABEL (w), t); g_free (t); /* The right help message */ update_message (swidget); notify_id = bastile_mateconf_notify (PUBLISH_TO_KEY, mateconf_notify, swidget); g_signal_connect (win, "destroy", G_CALLBACK (unhook_notification), GINT_TO_POINTER (notify_id)); keys = g_list_copy (keys); g_return_val_if_fail (!keys || BASTILE_IS_OBJECT (keys->data), win); g_object_set_data_full (G_OBJECT (swidget), "publish-keys", keys, (GDestroyNotify)g_list_free); return win; }
void meta_stack_set_positions (MetaStack *stack, GList *windows) { int i; GList *tmp; /* Make sure any adds or removes aren't in limbo -- is this needed? */ stack_ensure_sorted (stack); if (!lists_contain_same_windows (windows, stack->sorted)) { meta_warning ("This list of windows has somehow changed; not resetting " "positions of the windows.\n"); return; } g_list_free (stack->sorted); stack->sorted = g_list_copy (windows); stack->need_resort = TRUE; stack->need_constrain = TRUE; i = 0; tmp = windows; while (tmp != NULL) { MetaWindow *w = tmp->data; w->stack_position = i++; tmp = tmp->next; } meta_topic (META_DEBUG_STACK, "Reset the stack positions of (nearly) all windows\n"); stack_sync_to_server (stack); }
/*! \brief obtain a list of pages for an operation * * Descends the heirarchy of pages, if selected, and removes duplicate pages. * * \param [in] pages the list of pages to begin search * \param [in] descend alose locates subpages * \return a list of all the pages */ static GSList* get_pages (GList *pages, gboolean descend) { GList *input_list = g_list_copy (pages); GSList *output_list = NULL; GHashTable *visit_list = g_hash_table_new (NULL, NULL); while (input_list != NULL) { PAGE *page = (PAGE*) input_list->data; input_list = g_list_delete_link (input_list, input_list); if (page == NULL) { g_warning ("NULL page encountered"); continue; } /** \todo the following function becomes available in glib 2.32 */ /* if (g_hash_table_contains (visit_list, page)) { */ if (g_hash_table_lookup_extended (visit_list, page, NULL, NULL)) { continue; } output_list = g_slist_prepend (output_list, page); g_hash_table_insert (visit_list, page, NULL); if (descend) { input_list = g_list_concat (input_list, get_subpages (page)); } } g_hash_table_destroy (visit_list); return g_slist_reverse (output_list); }
gboolean project_close (void) { GList *tabs = NULL; int i = 0; tabs = g_list_copy(gummi_get_all_tabs()); // XXX: needs refactor /* Disable compile thread to prevent it from compiling nonexisting editor */ motion_stop_compile_thread(gummi->motion); tabmanager_set_active_tab(-1); for (i = 0; i < g_list_length (tabs); i++) { GuTabContext* tab = GU_TAB_CONTEXT (g_list_nth_data (tabs, i)); if (tab->editor->projfile != NULL) on_menu_close_activate(NULL, tab); } g_list_free(tabs); /* Resume compile by selecting an active tag */ if (gummi_get_all_tabs() != NULL) tabmanager_set_active_tab(0); motion_start_compile_thread(gummi->motion); return TRUE; }
static void impl_delete_thyself (RBSource *source) { GList *pl; GList *p; RBGenericPlayerSourcePrivate *priv = GENERIC_PLAYER_SOURCE_GET_PRIVATE (source); /* take a copy of the list first, as playlist_deleted_cb modifies priv->playlists */ pl = g_list_copy (priv->playlists); for (p = pl; p != NULL; p = p->next) { RBSource *playlist = RB_SOURCE (p->data); rb_source_delete_thyself (playlist); } g_list_free (priv->playlists); g_list_free (pl); priv->playlists = NULL; if (priv->import_errors != NULL) { rb_source_delete_thyself (priv->import_errors); priv->import_errors = NULL; } RB_SOURCE_CLASS (rb_generic_player_source_parent_class)->impl_delete_thyself (source); }
void handle_execute_for_all(void (*callback)(int idx, void *entry, void *p), void *param) { pthread_mutex_lock(&lock); GList *tmp = g_hash_table_get_keys(vdp_handles); GList *keys = g_list_copy(tmp); g_list_free(tmp); GList *ptr = g_list_first(keys); while (ptr) { HandleType handle = GPOINTER_TO_INT(ptr->data); void *item = g_hash_table_lookup(vdp_handles, GINT_TO_POINTER(handle)); if (item) { pthread_mutex_unlock(&lock); // TODO: race condition. Supply integer handle instead of pointer to fix. callback(handle, item, param); pthread_mutex_lock(&lock); } ptr = g_list_next(ptr); } g_list_free(keys); pthread_mutex_unlock(&lock); }
static void emit_changed (MetaPreference pref) { GList *tmp; GList *copy; meta_topic (META_DEBUG_PREFS, "Notifying listeners that pref %s changed\n", meta_preference_to_string (pref)); copy = g_list_copy (listeners); tmp = copy; while (tmp != NULL) { MetaPrefsListener *l = tmp->data; (* l->func) (pref, l->data); tmp = tmp->next; } g_list_free (copy); }
static void grl_metadata_store_source_store_metadata (GrlSource *source, GrlSourceStoreMetadataSpec *sms) { GRL_DEBUG ("grl_metadata_store_source_set_metadata"); const gchar *media_id, *source_id; GError *error = NULL; GList *failed_keys = NULL; source_id = grl_media_get_source (sms->media); media_id = grl_media_get_id (sms->media); /* We need the source id */ if (!source_id) { GRL_WARNING ("Failed to update metadata: source-id not available"); error = g_error_new (GRL_CORE_ERROR, GRL_CORE_ERROR_STORE_METADATA_FAILED, _("Failed to update metadata: %s"), _("\"source-id\" not available")); failed_keys = g_list_copy (sms->keys); } else { /* Special case for root categories */ if (!media_id) { media_id = ""; } failed_keys = write_keys (GRL_METADATA_STORE_SOURCE (source)->priv->db, source_id, media_id, sms, &error); } sms->callback (sms->source, sms->media, failed_keys, sms->user_data, error); g_clear_error (&error); g_list_free (failed_keys); }
static GstBufferList * _gst_buffer_list_copy (GstBufferList * list) { GstBufferList *list_copy; GList *tmp; g_return_val_if_fail (list != NULL, NULL); list_copy = gst_buffer_list_new (); /* shallow copy of list and pointers */ list_copy->buffers = g_list_copy (list->buffers); /* ref all buffers in the list */ tmp = list_copy->buffers; while (tmp) { if (tmp->data != GROUP_START && tmp->data != STOLEN) { tmp->data = gst_buffer_ref (GST_BUFFER_CAST (tmp->data)); } tmp = g_list_next (tmp); } return list_copy; }
dt_job_t * dt_camera_import_job_create(const char *jobcode, GList *images, struct dt_camera_t *camera, time_t time_override) { dt_job_t *job = dt_control_job_create(&dt_camera_import_job_run, "import selected images from camera"); if(!job) return NULL; dt_camera_import_t *params = (dt_camera_import_t *)calloc(1, sizeof(dt_camera_import_t)); if(!params) { dt_control_job_dispose(job); return NULL; } dt_control_job_set_params(job, params); /* intitialize import session for camera import job */ params->shared.session = dt_import_session_new(); dt_import_session_set_name(params->shared.session, jobcode); if(time_override != 0) dt_import_session_set_time(params->shared.session, time_override); params->fraction=0; params->images=g_list_copy(images); params->camera=camera; params->import_count=0; return job; }
static void impl_delete_thyself (RBDisplayPage *page) { GList *pl; GList *p; RBGenericPlayerSourcePrivate *priv = GET_PRIVATE (page); /* take a copy of the list first, as playlist_deleted_cb modifies priv->playlists */ pl = g_list_copy (priv->playlists); for (p = pl; p != NULL; p = p->next) { RBDisplayPage *playlist_page = RB_DISPLAY_PAGE (p->data); rb_display_page_delete_thyself (playlist_page); } g_list_free (priv->playlists); g_list_free (pl); priv->playlists = NULL; if (priv->import_errors != NULL) { rb_display_page_delete_thyself (RB_DISPLAY_PAGE (priv->import_errors)); priv->import_errors = NULL; } RB_DISPLAY_PAGE_CLASS (rb_generic_player_source_parent_class)->delete_thyself (page); }
static void ibus_factory_destroy (IBusFactory *factory) { GList *list; IBusFactoryPrivate *priv; priv = IBUS_FACTORY_GET_PRIVATE (factory); list = g_list_copy (priv->engine_list); g_list_foreach (list, (GFunc) ibus_object_destroy, NULL); g_list_free (priv->engine_list); g_list_free (list); priv->engine_list = NULL; if (priv->engine_table) { g_hash_table_destroy (priv->engine_table); } if (priv->connection) { g_object_unref (priv->connection); priv->connection = NULL; } IBUS_OBJECT_CLASS(ibus_factory_parent_class)->destroy (IBUS_OBJECT (factory)); }
/** * remove the currently selected items from the sheet * (especially their goocanvas representators) */ void sheet_delete_selection (Sheet *sheet) { GList *copy, *iter; g_return_if_fail (sheet != NULL); g_return_if_fail (IS_SHEET (sheet)); if (sheet->state != SHEET_STATE_NONE) return; copy = g_list_copy (sheet->priv->selected_objects); for (iter = copy; iter; iter = iter->next) { sheet_remove_item_in_sheet (SHEET_ITEM (iter->data), sheet); goo_canvas_item_remove (GOO_CANVAS_ITEM (iter->data)); } g_list_free (copy); // function <sheet_remove_item_in_sheet> // requires selected_objects, items, floating_objects // to be not NULL! g_list_free (sheet->priv->selected_objects); sheet->priv->selected_objects = NULL; }
static void anjuta_profile_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { AnjutaProfilePriv *priv = ANJUTA_PROFILE (object)->priv; g_return_if_fail (ANJUTA_IS_PROFILE (object)); switch (prop_id) { case PROP_PLUGIN_MANAGER: priv->plugin_manager = g_value_get_object (value); break; case PROP_PROFILE_NAME: g_return_if_fail (g_value_get_string (value) != NULL); g_free (priv->name); priv->name = g_strdup (g_value_get_string (value)); break; case PROP_PROFILE_PLUGINS: if (priv->plugins) g_list_free (priv->plugins); if (g_value_get_pointer (value)) priv->plugins = g_list_copy (g_value_get_pointer (value)); else priv->plugins = NULL; break; case PROP_SYNC_FILE: if (priv->sync_file) g_object_unref (priv->sync_file); priv->sync_file = g_value_dup_object (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/** * playlist_randomize: * @self: A #LomoPlaylist * * Randomize playlist */ void playlist_randomize (LomoPlaylist *self) { g_return_if_fail(LOMO_IS_PLAYLIST(self)); LomoPlaylistPrivate *priv = self->priv; GList *copy = NULL; GList *res = NULL; gpointer data; gint i, r, len = lomo_playlist_get_n_streams(self); copy = g_list_copy((GList *) lomo_playlist_get_playlist(self)); for (i = 0; i < len; i++) { r = g_random_int_range(0, len - i); data = g_list_nth_data(copy, r); copy = g_list_remove(copy, data); res = g_list_prepend(res, data); } g_list_free(priv->random_list); priv->random_list = res; }
static GList * smtp_transport_query_auth_types_sync (CamelService *service, GCancellable *cancellable, GError **error) { CamelSmtpTransport *transport = CAMEL_SMTP_TRANSPORT (service); CamelServiceAuthType *authtype; CamelProvider *provider; GList *types, *t, *next; if (!connect_to_server (service, cancellable, error)) return NULL; if (!transport->authtypes) { smtp_transport_disconnect_sync ( service, TRUE, cancellable, NULL); return NULL; } provider = camel_service_get_provider (service); types = g_list_copy (provider->authtypes); for (t = types; t; t = next) { authtype = t->data; next = t->next; if (!g_hash_table_lookup (transport->authtypes, authtype->authproto)) { types = g_list_remove_link (types, t); g_list_free_1 (t); } } smtp_transport_disconnect_sync (service, TRUE, cancellable, NULL); return types; }
/** * push_gcm_client_deliver_async: * @client: (in): A #PushGcmClient. * @identities: (element-type PushGcmIdentity*): A #GList of #PushGcmIdentity. * @message: A #PushGcmMessage. * @cancellable: (allow-none): A #GCancellable or %NULL. * @callback: A #GAsyncReadyCallback. * @user_data: User data for @callback. * * Asynchronously deliver a #PushGcmMessage to one or more GCM enabled * devices. */ void push_gcm_client_deliver_async (PushGcmClient *client, GList *identities, PushGcmMessage *message, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { PushGcmClientPrivate *priv; GSimpleAsyncResult *simple; SoupMessage *request; const gchar *registration_id; const gchar *collapse_key; JsonGenerator *g; JsonObject *obj; JsonObject *data; JsonObject *mdata; JsonArray *ar; JsonNode *node; GList *iter; GList *list; gchar *str; gsize length; guint time_to_live; ENTRY; g_return_if_fail(PUSH_IS_GCM_CLIENT(client)); g_return_if_fail(identities); g_return_if_fail(PUSH_IS_GCM_MESSAGE(message)); g_return_if_fail(!cancellable || G_IS_CANCELLABLE(cancellable)); g_return_if_fail(callback); priv = client->priv; request = soup_message_new("POST", PUSH_GCM_CLIENT_URL); ar = json_array_new(); for (iter = identities; iter; iter = iter->next) { g_assert(PUSH_IS_GCM_IDENTITY(iter->data)); registration_id = push_gcm_identity_get_registration_id(iter->data); json_array_add_string_element(ar, registration_id); } str = g_strdup_printf("key=%s", priv->auth_token); soup_message_headers_append(request->request_headers, "Authorization", str); g_free(str); soup_message_headers_append(request->request_headers, "Accept", "application/json"); data = json_object_new(); if ((collapse_key = push_gcm_message_get_collapse_key(message))) { json_object_set_string_member(data, "collapse_key", collapse_key); } json_object_set_boolean_member(data, "delay_while_idle", push_gcm_message_get_delay_while_idle(message)); json_object_set_boolean_member(data, "dry_run", push_gcm_message_get_dry_run(message)); if ((time_to_live = push_gcm_message_get_time_to_live(message))) { json_object_set_int_member(data, "time_to_live", time_to_live); } if ((mdata = push_gcm_message_get_data(message))) { json_object_set_object_member(data, "data", mdata); } obj = json_object_new(); json_object_set_array_member(obj, "registration_ids", ar); json_object_set_object_member(obj, "data", data); node = json_node_new(JSON_NODE_OBJECT); json_node_set_object(node, obj); json_object_unref(obj); g = json_generator_new(); json_generator_set_pretty(g, TRUE); json_generator_set_indent(g, 2); json_generator_set_root(g, node); str = json_generator_to_data(g, &length); json_node_free(node); g_object_unref(g); g_print("REQUEST: \"%s\"\n", str); soup_message_set_request(request, "application/json", SOUP_MEMORY_TAKE, str, length); simple = g_simple_async_result_new(G_OBJECT(client), callback, user_data, push_gcm_client_deliver_async); /* * Keep the list of identities around until we receive our result. * We need them to key with the resulting array. */ list = g_list_copy(identities); g_list_foreach(list, (GFunc)g_object_ref, NULL); g_object_set_data_full(G_OBJECT(simple), "identities", list, _push_gcm_identities_free); soup_session_queue_message(SOUP_SESSION(client), request, push_gcm_client_deliver_cb, simple); EXIT; }
/** * nautilus_directory_list_copy * * Copy the list of directories, making a new ref of each, * @list: GList of directories. **/ GList * nautilus_directory_list_copy (GList *list) { return g_list_copy (nautilus_directory_list_ref (list)); }
static void insert_metric_result (struct rspamd_task *task, struct metric *metric, const gchar *symbol, double flag, GList * opts, gboolean single) { struct metric_result *metric_res; struct symbol *s; gdouble w, *gr_score = NULL; struct rspamd_symbol_def *sdef; struct rspamd_symbols_group *gr = NULL; const ucl_object_t *mobj, *sobj; metric_res = rspamd_create_metric_result (task, metric->name); sdef = g_hash_table_lookup (metric->symbols, symbol); if (sdef == NULL) { w = 0.0; } else { w = (*sdef->weight_ptr) * flag; gr = sdef->gr; if (gr != NULL) { gr_score = g_hash_table_lookup (metric_res->sym_groups, gr); if (gr_score == NULL) { gr_score = rspamd_mempool_alloc (task->task_pool, sizeof (gdouble)); *gr_score = 0; g_hash_table_insert (metric_res->sym_groups, gr, gr_score); } } } if (task->settings) { mobj = ucl_object_find_key (task->settings, metric->name); if (mobj) { gdouble corr; sobj = ucl_object_find_key (mobj, symbol); if (sobj != NULL && ucl_object_todouble_safe (sobj, &corr)) { msg_debug ("settings: changed weight of symbol %s from %.2f to %.2f", symbol, w, corr); w = corr * flag; } } } /* XXX: does not take grow factor into account */ if (gr != NULL && gr_score != NULL && gr->max_score > 0.0) { if (*gr_score >= gr->max_score) { msg_info ("maximum group score %.2f for group %s has been reached," " ignoring symbol %s with weight %.2f", gr->max_score, gr->name, symbol, w); return; } else if (*gr_score + w > gr->max_score) { w = gr->max_score - *gr_score; } *gr_score += w; } /* Add metric score */ if ((s = g_hash_table_lookup (metric_res->symbols, symbol)) != NULL) { if (sdef && sdef->one_shot) { /* * For one shot symbols we do not need to add them again, so * we just force single behaviour here */ single = TRUE; } if (s->options && opts && opts != s->options) { /* Append new options */ s->options = g_list_concat (s->options, g_list_copy (opts)); /* * Note that there is no need to add new destructor of GList as elements of appended * GList are used directly, so just free initial GList */ } else if (opts) { s->options = g_list_copy (opts); rspamd_mempool_add_destructor (task->task_pool, (rspamd_mempool_destruct_t) g_list_free, s->options); } if (!single) { /* Handle grow factor */ if (metric_res->grow_factor && w > 0) { w *= metric_res->grow_factor; metric_res->grow_factor *= metric->grow_factor; } s->score += w; metric_res->score += w; } else { if (fabs (s->score) < fabs (w)) { /* Replace less weight with a bigger one */ metric_res->score = metric_res->score - s->score + w; s->score = w; } } } else { s = rspamd_mempool_alloc (task->task_pool, sizeof (struct symbol)); /* Handle grow factor */ if (metric_res->grow_factor && w > 0) { w *= metric_res->grow_factor; metric_res->grow_factor *= metric->grow_factor; } else if (w > 0) { metric_res->grow_factor = metric->grow_factor; } s->score = w; s->name = symbol; s->def = sdef; metric_res->score += w; if (opts) { s->options = g_list_copy (opts); rspamd_mempool_add_destructor (task->task_pool, (rspamd_mempool_destruct_t) g_list_free, s->options); } else { s->options = NULL; } g_hash_table_insert (metric_res->symbols, (gpointer) symbol, s); } debug_task ("symbol %s, score %.2f, metric %s, factor: %f", symbol, s->score, metric->name, w); }
/* * get files list */ GList* get_files () { return g_list_copy(files); }
void gnc_split_register_load (SplitRegister *reg, GList * slist, Account *default_account) { SRInfo *info; Transaction *pending_trans; CursorBuffer *cursor_buffer; GHashTable *trans_table = NULL; CellBlock *cursor_header; CellBlock *lead_cursor; CellBlock *split_cursor; Transaction *blank_trans; Transaction *find_trans; Transaction *trans; CursorClass find_class; Split *find_trans_split; Split *blank_split; Split *find_split; Split *split; Table *table; GList *node; gboolean start_primary_color = TRUE; gboolean found_pending = FALSE; gboolean need_divider_upper = FALSE; gboolean found_divider_upper = FALSE; gboolean found_divider = FALSE; gboolean has_last_num = FALSE; gboolean multi_line; gboolean dynamic; gboolean we_own_slist = FALSE; gboolean use_autoreadonly = qof_book_uses_autoreadonly(gnc_get_current_book()); VirtualCellLocation vcell_loc; VirtualLocation save_loc; int new_trans_split_row = -1; int new_trans_row = -1; int new_split_row = -1; time64 present, autoreadonly_time = 0; g_return_if_fail(reg); table = reg->table; g_return_if_fail(table); info = gnc_split_register_get_info (reg); g_return_if_fail(info); ENTER("reg=%p, slist=%p, default_account=%p", reg, slist, default_account); blank_split = xaccSplitLookup (&info->blank_split_guid, gnc_get_current_book ()); pending_trans = xaccTransLookup (&info->pending_trans_guid, gnc_get_current_book ()); /* make sure we have a blank split */ if (blank_split == NULL) { /* Wouldn't it be a bug to open the new transaction if there was * already a pending transaction? */ g_assert(pending_trans == NULL); blank_split = create_blank_split (default_account, info); } blank_trans = xaccSplitGetParent (blank_split); DEBUG("blank_split=%p, blank_trans=%p, pending_trans=%p", blank_split, blank_trans, pending_trans); info->default_account = *xaccAccountGetGUID (default_account); // gnc_table_leave_update (table, table->current_cursor_loc); multi_line = (reg->style == REG_STYLE_JOURNAL); dynamic = (reg->style == REG_STYLE_AUTO_LEDGER); lead_cursor = gnc_split_register_get_passive_cursor (reg); split_cursor = gnc_table_layout_get_cursor (table->layout, CURSOR_SPLIT); /* figure out where we are going to. */ if (info->traverse_to_new) { find_trans = blank_trans; find_split = NULL; find_trans_split = blank_split; find_class = CURSOR_CLASS_SPLIT; } else { find_trans = info->cursor_hint_trans; find_split = info->cursor_hint_split; find_trans_split = info->cursor_hint_trans_split; find_class = info->cursor_hint_cursor_class; } save_loc = table->current_cursor_loc; /* If the current cursor has changed we save the values for later * possible restoration. */ if (gnc_table_current_cursor_changed (table, TRUE) && (find_split == gnc_split_register_get_current_split (reg))) { cursor_buffer = gnc_cursor_buffer_new (); gnc_table_save_current_cursor (table, cursor_buffer); } else cursor_buffer = NULL; /* disable move callback -- we don't want the cascade of * callbacks while we are fiddling with loading the register */ gnc_table_control_allow_move (table->control, FALSE); /* invalidate the cursor */ { VirtualLocation virt_loc; gnc_virtual_location_init(&virt_loc); gnc_table_move_cursor_gui (table, virt_loc); } /* make sure that the header is loaded */ vcell_loc.virt_row = 0; vcell_loc.virt_col = 0; cursor_header = gnc_table_layout_get_cursor (table->layout, CURSOR_HEADER); gnc_table_set_vcell (table, cursor_header, NULL, TRUE, TRUE, vcell_loc); vcell_loc.virt_row++; /* get the current time and reset the dividing row */ present = gnc_time64_get_today_end (); if (use_autoreadonly) { GDate *d = qof_book_get_autoreadonly_gdate(gnc_get_current_book()); // "d" is NULL if use_autoreadonly is FALSE autoreadonly_time = d ? timespecToTime64(gdate_to_timespec(*d)) : 0; g_date_free(d); } if (info->first_pass) { if (default_account) { const char *last_num = xaccAccountGetLastNum (default_account); if (last_num) { NumCell *cell; cell = (NumCell *) gnc_table_layout_get_cell(table->layout, NUM_CELL); gnc_num_cell_set_last_num (cell, last_num); has_last_num = TRUE; } } /* load up account names into the transfer combobox menus */ gnc_split_register_load_xfer_cells (reg, default_account); gnc_split_register_load_recn_cells (reg); gnc_split_register_load_type_cells (reg); } if (info->separator_changed) change_account_separator (info, table, reg); table->model->dividing_row_upper = -1; table->model->dividing_row = -1; // Ensure that the transaction and splits being edited are in the split // list we're about to load. if (pending_trans != NULL) { for (node = xaccTransGetSplitList(pending_trans); node; node = node->next) { Split *pending_split = (Split*)node->data; if (!xaccTransStillHasSplit(pending_trans, pending_split)) continue; if (g_list_find(slist, pending_split) != NULL) continue; if (g_list_find_custom(slist, pending_trans, _find_split_with_parent_txn) != NULL) continue; if (!we_own_slist) { // lazy-copy slist = g_list_copy(slist); we_own_slist = TRUE; } slist = g_list_append(slist, pending_split); } } if (multi_line) trans_table = g_hash_table_new (g_direct_hash, g_direct_equal); /* populate the table */ for (node = slist; node; node = node->next) { split = node->data; trans = xaccSplitGetParent (split); if (!xaccTransStillHasSplit(trans, split)) continue; if (pending_trans == trans) found_pending = TRUE; /* If the transaction has only one split, and it's not our * pending_trans, then it's another register's blank split and * we don't want to see it. */ else if (xaccTransCountSplits (trans) == 1 && xaccSplitGetAccount (split) == NULL) continue; /* Do not load splits from the blank transaction. */ if (trans == blank_trans) continue; if (multi_line) { /* Skip this split if its transaction has already been loaded. */ if (g_hash_table_lookup (trans_table, trans)) continue; g_hash_table_insert (trans_table, trans, trans); } if (info->show_present_divider && use_autoreadonly && !found_divider_upper) { if (xaccTransGetDate (trans) >= autoreadonly_time) { table->model->dividing_row_upper = vcell_loc.virt_row; found_divider_upper = TRUE; } else { need_divider_upper = TRUE; } } if (info->show_present_divider && !found_divider && (xaccTransGetDate (trans) > present)) { table->model->dividing_row = vcell_loc.virt_row; found_divider = TRUE; } /* If this is the first load of the register, * fill up the quickfill cells. */ if (info->first_pass) add_quickfill_completions(reg->table->layout, trans, split, has_last_num); if (trans == find_trans) new_trans_row = vcell_loc.virt_row; if (split == find_trans_split) new_trans_split_row = vcell_loc.virt_row; gnc_split_register_add_transaction (reg, trans, split, lead_cursor, split_cursor, multi_line, start_primary_color, TRUE, find_trans, find_split, find_class, &new_split_row, &vcell_loc); if (!multi_line) start_primary_color = !start_primary_color; } if (multi_line) g_hash_table_destroy (trans_table); /* add the blank split at the end. */ if (pending_trans == blank_trans) found_pending = TRUE; /* No upper divider yet? Store it now */ if (info->show_present_divider && use_autoreadonly && !found_divider_upper && need_divider_upper) { table->model->dividing_row_upper = vcell_loc.virt_row; found_divider_upper = TRUE; } if (blank_trans == find_trans) new_trans_row = vcell_loc.virt_row; if (blank_split == find_trans_split) new_trans_split_row = vcell_loc.virt_row; /* If we didn't find the pending transaction, it was removed * from the account. */ if (!found_pending) { info->pending_trans_guid = *guid_null (); if (xaccTransIsOpen (pending_trans)) xaccTransCommitEdit (pending_trans); else if (pending_trans) g_assert_not_reached(); pending_trans = NULL; } /* go to blank on first pass */ if (info->first_pass) { new_split_row = -1; new_trans_split_row = -1; new_trans_row = -1; save_loc.vcell_loc = vcell_loc; save_loc.phys_row_offset = 0; save_loc.phys_col_offset = 0; } gnc_split_register_add_transaction (reg, blank_trans, blank_split, lead_cursor, split_cursor, multi_line, start_primary_color, info->blank_split_edited, find_trans, find_split, find_class, &new_split_row, &vcell_loc); /* resize the table to the sizes we just counted above */ /* num_virt_cols is always one. */ gnc_table_set_size (table, vcell_loc.virt_row, 1); /* restore the cursor to its rightful position */ { VirtualLocation trans_split_loc; if (new_split_row > 0) save_loc.vcell_loc.virt_row = new_split_row; else if (new_trans_split_row > 0) save_loc.vcell_loc.virt_row = new_trans_split_row; else if (new_trans_row > 0) save_loc.vcell_loc.virt_row = new_trans_row; trans_split_loc = save_loc; gnc_split_register_get_trans_split (reg, save_loc.vcell_loc, &trans_split_loc.vcell_loc); if (dynamic || multi_line || info->trans_expanded) { gnc_table_set_virt_cell_cursor( table, trans_split_loc.vcell_loc, gnc_split_register_get_active_cursor (reg)); gnc_split_register_set_trans_visible (reg, trans_split_loc.vcell_loc, TRUE, multi_line); info->trans_expanded = (reg->style == REG_STYLE_LEDGER); } else { save_loc = trans_split_loc; info->trans_expanded = FALSE; } if (gnc_table_find_close_valid_cell (table, &save_loc, FALSE)) { gnc_table_move_cursor_gui (table, save_loc); new_split_row = save_loc.vcell_loc.virt_row; if (find_split == gnc_split_register_get_current_split (reg)) gnc_table_restore_current_cursor (table, cursor_buffer); } } gnc_cursor_buffer_destroy (cursor_buffer); cursor_buffer = NULL; update_info (info, reg); gnc_split_register_set_cell_fractions( reg, gnc_split_register_get_current_split (reg)); gnc_table_refresh_gui (table, TRUE); gnc_split_register_show_trans (reg, table->current_cursor_loc.vcell_loc); /* enable callback for cursor user-driven moves */ gnc_table_control_allow_move (table->control, TRUE); if (we_own_slist) g_list_free(slist); LEAVE(" "); }
/* * get autos list */ GList* get_autos () { return g_list_copy(autos); }
/* * get watches list */ GList* get_watches () { return g_list_copy(watches); }
// paste xournal native data void clipboard_paste_from_xournal(GtkSelectionData *sel_data) { unsigned char *p; int nitems, npts, i, len; struct Item *item; double hoffset, voffset, cx, cy; double *pf; int sx, sy, wx, wy; reset_selection(); ui.selection = g_new(struct Selection, 1); p = sel_data->data + sizeof(int); g_memmove(&nitems, p, sizeof(int)); p+= sizeof(int); ui.selection->type = ITEM_SELECTRECT; ui.selection->layer = ui.cur_layer; g_memmove(&ui.selection->bbox, p, sizeof(struct BBox)); p+= sizeof(struct BBox); ui.selection->items = NULL; // find by how much we translate the pasted selection gnome_canvas_get_scroll_offsets(canvas, &sx, &sy); gdk_window_get_geometry(GTK_WIDGET(canvas)->window, NULL, NULL, &wx, &wy, NULL); gnome_canvas_window_to_world(canvas, sx + wx/2, sy + wy/2, &cx, &cy); cx -= ui.cur_page->hoffset; cy -= ui.cur_page->voffset; if (cx + (ui.selection->bbox.right-ui.selection->bbox.left)/2 > ui.cur_page->width) cx = ui.cur_page->width - (ui.selection->bbox.right-ui.selection->bbox.left)/2; if (cx - (ui.selection->bbox.right-ui.selection->bbox.left)/2 < 0) cx = (ui.selection->bbox.right-ui.selection->bbox.left)/2; if (cy + (ui.selection->bbox.bottom-ui.selection->bbox.top)/2 > ui.cur_page->height) cy = ui.cur_page->height - (ui.selection->bbox.bottom-ui.selection->bbox.top)/2; if (cy - (ui.selection->bbox.bottom-ui.selection->bbox.top)/2 < 0) cy = (ui.selection->bbox.bottom-ui.selection->bbox.top)/2; hoffset = cx - (ui.selection->bbox.right+ui.selection->bbox.left)/2; voffset = cy - (ui.selection->bbox.top+ui.selection->bbox.bottom)/2; ui.selection->bbox.left += hoffset; ui.selection->bbox.right += hoffset; ui.selection->bbox.top += voffset; ui.selection->bbox.bottom += voffset; ui.selection->canvas_item = gnome_canvas_item_new(ui.cur_layer->group, gnome_canvas_rect_get_type(), "width-pixels", 1, "outline-color-rgba", 0x000000ff, "fill-color-rgba", 0x80808040, "x1", ui.selection->bbox.left, "x2", ui.selection->bbox.right, "y1", ui.selection->bbox.top, "y2", ui.selection->bbox.bottom, NULL); make_dashed(ui.selection->canvas_item); while (nitems-- > 0) { item = g_new(struct Item, 1); ui.selection->items = g_list_append(ui.selection->items, item); ui.cur_layer->items = g_list_append(ui.cur_layer->items, item); ui.cur_layer->nitems++; g_memmove(&item->type, p, sizeof(int)); p+= sizeof(int); if (item->type == ITEM_STROKE) { g_memmove(&item->brush, p, sizeof(struct Brush)); p+= sizeof(struct Brush); g_memmove(&npts, p, sizeof(int)); p+= sizeof(int); item->path = gnome_canvas_points_new(npts); pf = (double *)p; for (i=0; i<npts; i++) { item->path->coords[2*i] = pf[2*i] + hoffset; item->path->coords[2*i+1] = pf[2*i+1] + voffset; } p+= 2*item->path->num_points*sizeof(double); if (item->brush.variable_width) { item->widths = g_memdup(p, (item->path->num_points-1)*sizeof(double)); p+= (item->path->num_points-1)*sizeof(double); } else item->widths = NULL; update_item_bbox(item); make_canvas_item_one(ui.cur_layer->group, item); } if (item->type == ITEM_TEXT) { g_memmove(&item->brush, p, sizeof(struct Brush)); p+= sizeof(struct Brush); g_memmove(&item->bbox.left, p, sizeof(double)); p+= sizeof(double); g_memmove(&item->bbox.top, p, sizeof(double)); p+= sizeof(double); item->bbox.left += hoffset; item->bbox.top += voffset; g_memmove(&len, p, sizeof(int)); p+= sizeof(int); item->text = g_malloc(len+1); g_memmove(item->text, p, len+1); p+= len+1; g_memmove(&len, p, sizeof(int)); p+= sizeof(int); item->font_name = g_malloc(len+1); g_memmove(item->font_name, p, len+1); p+= len+1; g_memmove(&item->font_size, p, sizeof(double)); p+= sizeof(double); make_canvas_item_one(ui.cur_layer->group, item); } if (item->type == ITEM_IMAGE) { item->canvas_item = NULL; item->image_png = NULL; item->image_png_len = 0; g_memmove(&item->bbox, p, sizeof(struct BBox)); p+= sizeof(struct BBox); item->bbox.left += hoffset; item->bbox.right += hoffset; item->bbox.top += voffset; item->bbox.bottom += voffset; g_memmove(&item->image_png_len, p, sizeof(gsize)); p+= sizeof(gsize); if (item->image_png_len > 0) { item->image_png = g_memdup(p, item->image_png_len); item->image = pixbuf_from_buffer(item->image_png, item->image_png_len); p+= item->image_png_len; } else { item->image = NULL; } make_canvas_item_one(ui.cur_layer->group, item); } } prepare_new_undo(); undo->type = ITEM_PASTE; undo->layer = ui.cur_layer; undo->itemlist = g_list_copy(ui.selection->items); gtk_selection_data_free(sel_data); update_copy_paste_enabled(); update_color_menu(); update_thickness_buttons(); update_color_buttons(); update_font_button(); update_cursor(); // FIXME: can't know if pointer is within selection! }
/* * bt_edit_application_check_missing: * @self: the edit application * * Run gstreamer element checks. If elements are missing, if shows a dialog with * element-names and brief description what will not work. * * Returns: %TRUE is no critical elements are missing */ static gboolean bt_edit_application_check_missing (const BtEditApplication * self) { GList *missing_core_elements, *missing_edit_elements = NULL, *missing_elements; GList *edit_elements = NULL; gboolean res = TRUE, missing = FALSE; if ((missing_core_elements = bt_gst_check_core_elements ())) { missing = TRUE; res = FALSE; } // TODO(ensonic): check recording 'formats' -> use GstEncodeBin edit_elements = g_list_prepend (NULL, "level"); if ((missing_elements = bt_gst_check_elements (edit_elements))) { missing_edit_elements = g_list_concat (missing_edit_elements, g_list_copy (missing_elements)); missing_edit_elements = g_list_append (missing_edit_elements, _("-> You will not see any level-meters.")); missing = TRUE; } g_list_free (edit_elements); edit_elements = g_list_prepend (NULL, "spectrum"); if ((missing_elements = bt_gst_check_elements (edit_elements))) { missing_edit_elements = g_list_concat (missing_edit_elements, g_list_copy (missing_elements)); missing_edit_elements = g_list_append (missing_edit_elements, _ ("-> You will not see the frequency spectrum in the analyzer window.")); missing = TRUE; } g_list_free (edit_elements); edit_elements = g_list_prepend (NULL, "playbin"); if ((missing_elements = bt_gst_check_elements (edit_elements))) { missing_edit_elements = g_list_concat (missing_edit_elements, g_list_copy (missing_elements)); missing_edit_elements = g_list_append (missing_edit_elements, _ ("-> Sample playback previews from the wavetable page will not work.")); missing = TRUE; } g_list_free (edit_elements); // show missing dialog if (missing) { GtkWidget *dialog; if ((dialog = GTK_WIDGET (bt_missing_framework_elements_dialog_new (missing_core_elements, missing_edit_elements)))) { bt_edit_application_attach_child_window (self, GTK_WINDOW (dialog)); gtk_widget_show_all (dialog); gtk_dialog_run (GTK_DIALOG (dialog)); bt_missing_framework_elements_dialog_apply (BT_MISSING_FRAMEWORK_ELEMENTS_DIALOG (dialog)); gtk_widget_destroy (dialog); } } // don't free. its static //g_list_free(missing_core_elements); g_list_free (missing_edit_elements); return res; }
static void fs_rtp_stream_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { FsRtpStream *self = FS_RTP_STREAM (object); GList *item; switch (prop_id) { case PROP_SESSION: self->priv->session = FS_RTP_SESSION (g_value_dup_object (value)); break; case PROP_PARTICIPANT: self->participant = FS_RTP_PARTICIPANT (g_value_dup_object (value)); break; case PROP_DIRECTION: { FsStreamTransmitter *st = NULL; GList *copy = NULL; FsRtpSession *session = fs_rtp_stream_get_session (self, NULL); FsStreamDirection dir; if (!session) { self->priv->direction = g_value_get_flags (value); return; } FS_RTP_SESSION_LOCK (session); if (self->priv->sending_changed_locked_cb && (self->priv->direction & FS_DIRECTION_SEND) != (g_value_get_flags (value) & FS_DIRECTION_SEND)) self->priv->sending_changed_locked_cb (self, g_value_get_flags (value) & FS_DIRECTION_SEND, self->priv->user_data_for_cb); dir = self->priv->direction = g_value_get_flags (value); FS_RTP_SESSION_UNLOCK (session); st = fs_rtp_stream_get_stream_transmitter (self, NULL); if (st) { g_object_set (self->priv->stream_transmitter, "sending", dir & FS_DIRECTION_SEND, NULL); g_object_unref (st); } FS_RTP_SESSION_LOCK (session); copy = g_list_copy (g_list_first (self->substreams)); g_list_foreach (copy, (GFunc) g_object_ref, NULL); FS_RTP_SESSION_UNLOCK (session); for (item = copy; item; item = g_list_next (item)) g_object_set (G_OBJECT (item->data), "receiving", ((dir & FS_DIRECTION_RECV) != 0), NULL); g_list_foreach (copy, (GFunc) g_object_unref, NULL); g_list_free (copy); g_object_unref (session); } break; case PROP_RTP_HEADER_EXTENSIONS: { FsRtpSession *session = fs_rtp_stream_get_session (self, NULL); if (session) { FS_RTP_SESSION_LOCK (session); fs_rtp_header_extension_list_destroy (self->hdrext); self->hdrext = g_value_dup_boxed (value); FS_RTP_SESSION_UNLOCK (session); /* The callbadck can not fail because it does not change * the codecs */ self->priv->new_remote_codecs_cb (NULL, NULL, NULL, self->priv->user_data_for_cb); g_object_unref (session); } } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static struct MultipleSearchData * start_multiple_search_operation (guint search_id, const GList *sources, const gchar *text, const GList *keys, const GList *skip_counts, gint count, GrlOperationOptions *options, GrlSourceResultCb user_callback, gpointer user_data) { GRL_DEBUG ("start_multiple_search_operation"); struct MultipleSearchData *msd; GList *iter_sources, *iter_skips; guint n; gint first_count, individual_count; /* Prepare data required to execute the operation */ msd = g_new0 (struct MultipleSearchData, 1); msd->table = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free); msd->remaining = (count == GRL_COUNT_INFINITY) ? GRL_COUNT_INFINITY : (count - 1); msd->search_id = search_id; msd->text = g_strdup (text); msd->keys = g_list_copy ((GList *) keys); msd->options = g_object_ref (options); msd->user_callback = user_callback; msd->user_data = user_data; /* Compute the # of items to request by each source */ n = g_list_length ((GList *) sources); if (count == GRL_COUNT_INFINITY) { individual_count = GRL_COUNT_INFINITY; first_count = GRL_COUNT_INFINITY; } else { individual_count = count / n; first_count = individual_count + count % n; } /* Issue search operations on each source */ iter_sources = (GList *) sources; iter_skips = (GList *) skip_counts; n = 0; while (iter_sources) { GrlSource *source; guint c, id; struct ResultCount *rc; guint skip; source = GRL_SOURCE (iter_sources->data); /* c is the count to use for this source */ c = (n == 0) ? first_count : individual_count; n++; /* Only interested in sources with c != 0 */ if (c != 0) { GrlOperationOptions *source_options = NULL; GrlCaps *source_caps; /* We use ResultCount to keep track of results emitted by this source */ rc = g_new0 (struct ResultCount, 1); rc->count = c; g_hash_table_insert (msd->table, source, rc); /* Check if we have to apply a "skip" parameter to this source (useful when we are chaining queries to complete the result count) */ if (iter_skips) { skip = GPOINTER_TO_INT (iter_skips->data); } else { skip = 0; } source_caps = grl_source_get_caps (source, GRL_OP_SEARCH); grl_operation_options_obey_caps (options, source_caps, &source_options, NULL); grl_operation_options_set_skip (source_options, skip); grl_operation_options_set_count (source_options, rc->count); /* Execute the search on this source */ id = grl_source_search (source, msd->text, msd->keys, source_options, multiple_search_cb, msd); GRL_DEBUG ("Operation %s:%u: Searching %u items from offset %u", grl_source_get_name (GRL_SOURCE (source)), id, rc->count, skip); g_object_unref (source_options); /* Keep track of this operation and this source */ msd->search_ids = g_list_prepend (msd->search_ids, GINT_TO_POINTER (id)); msd->sources = g_list_prepend (msd->sources, source); msd->sources_count++; } /* Move to the next source */ iter_sources = g_list_next (iter_sources); iter_skips = g_list_next (iter_skips); }
/*! \brief Get a list of symbols available from a given source. * \par Function Description * Get a \b GList containing all of the symbols available from \a * source. * * \warning The returned \b GList will not be consistent over a call to * s_clib_refresh(). It should be freed when no longer needed. * * \param source Source to be examined. * \return A \b GList of #CLibSymbol. */ GList *s_clib_source_get_symbols (const CLibSource *source) { if (source == NULL) return NULL; return g_list_copy(source->symbols); }
/*! \brief Find all symbols matching a pattern. * * \par Function Description * Searches the library, returning all symbols whose * names match \a pattern. * * Two search modes are available: \b CLIB_EXACT, where \a pattern is * compared to the symbol name using strcmp(), and \b CLIB_GLOB, * where \a pattern is assumed to be a glob pattern (see the GLib * documentation for details of the glob syntax applicable). * * \warning The #CLibSymbol instances in the \b GList returned belong * to the component library, and should be considered constants; they * should not be manipulated or free()'d. On the other hand, the \b * GList returned must be freed with \b g_list_free() when no longer * needed. Note that the values returned will be invalidated by a * call to s_clib_free() or s_clib_refresh(). * * \param pattern The pattern to match against. * \param mode The search mode to use. * \return A \b GList of matching #CLibSymbol structures. */ GList *s_clib_search (const gchar *pattern, const CLibSearchMode mode) { GList *sourcelist; GList *symlist; GList *result = NULL; CLibSource *source; CLibSymbol *symbol; GPatternSpec *globpattern = NULL; gchar *key; gchar keytype; if (pattern == NULL) return NULL; /* Use different cache keys depending on what sort of search is being done */ switch (mode) { case CLIB_GLOB: keytype = 'g'; break; case CLIB_EXACT: keytype = 's'; break; default: g_critical ("s_clib_search: Bad search mode %1$i\n", mode); return NULL; } key = g_strdup_printf("%c%s", keytype, pattern); /* Check to see if the query is already in the cache */ result = (GList *) g_hash_table_lookup (clib_search_cache, key); if (result != NULL) { g_free (key); return g_list_copy (result); } if (mode == CLIB_GLOB) { globpattern = g_pattern_spec_new(pattern); } for (sourcelist = clib_sources; sourcelist != NULL; sourcelist = g_list_next(sourcelist)) { source = (CLibSource *) sourcelist->data; for (symlist = source->symbols; symlist != NULL; symlist = g_list_next(symlist)) { symbol = (CLibSymbol *) symlist->data; switch (mode) { case CLIB_EXACT: if (strcmp (pattern, symbol->name) == 0) { result = g_list_prepend (result, symbol); } break; case CLIB_GLOB: if (g_pattern_match_string (globpattern, symbol->name)) { result = g_list_prepend (result, symbol); } break; } } } result = g_list_reverse (result); if (globpattern != NULL) { g_pattern_spec_free (globpattern); } g_hash_table_insert (clib_search_cache, key, g_list_copy (result)); /* __don't__ free key here, it's stored by the hash table! */ return result; }
gboolean dijkstra_to (GList *nodes, Node *source, Node *target, gint width, gint height, gint *distances, Node **previous) { gint nr; GList *unvisited_nodes, *current; for (current = g_list_first (nodes); previous != NULL && current != NULL; current = g_list_next (current)) { Node *node; node = (Node *) current->data; previous[node->j * width + node->i] = NULL; } distances[source->j * width + source->i] = 0; unvisited_nodes = g_list_copy (nodes); nr = 0; while (unvisited_nodes != NULL) { Node *node; GList *current_neighbor, *shorter_dist_node, *cur_node; shorter_dist_node = g_list_first (unvisited_nodes); cur_node = g_list_next (shorter_dist_node); while (cur_node != NULL) { Node *value, *shorter_dist; value = (Node *) cur_node->data; shorter_dist = (Node *) shorter_dist_node->data; if (distances[shorter_dist->j * width + shorter_dist->i] == -1 || (distances[value->j * width + value->i] != -1 && distances[value->j * width + value->i] < distances[shorter_dist->j * width + shorter_dist->i])) { shorter_dist_node = cur_node; } cur_node = g_list_next (cur_node); } node = (Node *) shorter_dist_node->data; if (distances[node->j * width + node->i] == -1) { break; } current_neighbor = g_list_first (node->neighbors); while (current_neighbor) { gint dist; Node *neighbor; neighbor = (Node *) current_neighbor->data; dist = get_distance (node, neighbor) + distances[node->j * width + node->i]; if (distances[neighbor->j * width + neighbor->i] == -1 || dist < distances[neighbor->j * width + neighbor->i]) { distances[neighbor->j * width + neighbor->i] = dist; if (previous != NULL) { previous[neighbor->j * width + neighbor->i] = node; } nr++; } if (target != NULL && neighbor == target) { g_list_free (unvisited_nodes); return TRUE; } current_neighbor = g_list_next (current_neighbor); } unvisited_nodes = g_list_delete_link (unvisited_nodes, shorter_dist_node); } g_list_free (unvisited_nodes); return FALSE; }