/* * e-client-combo-box.c * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) version 3. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with the program; if not, see * */ /** * SECTION: e-client-combo-box * @include: e-util/e-util.h * @short_description: Combo box of #EClient instances * * #EClientComboBox extends the functionality of #ESourceComboBox by * providing convenient access to #EClient instances with #EClientCache. * * As a future enhancement, this widget may also display status information * about the backends associated with the displayed data sources, similar to * #EClientSelector. **/ #include "e-client-combo-box.h" #define E_CLIENT_COMBO_BOX_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ ((obj), E_TYPE_CLIENT_COMBO_BOX, EClientComboBoxPrivate)) struct _EClientComboBoxPrivate { EClientCache *client_cache; }; enum { PROP_0, PROP_CLIENT_CACHE }; G_DEFINE_TYPE ( EClientComboBox, e_client_combo_box, E_TYPE_SOURCE_COMBO_BOX) static void client_combo_box_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) { switch (property_id) { case PROP_CLIENT_CACHE: e_client_combo_box_set_client_cache ( E_CLIENT_COMBO_BOX (object), g_value_get_object (value)); return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void client_combo_box_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { switch (property_id) { case PROP_CLIENT_CACHE: g_value_take_object ( value, e_client_combo_box_ref_client_cache ( E_CLIENT_COMBO_BOX (object))); return; } G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); } static void client_combo_box_dispose (GObject *object) { EClientComboBoxPrivate *priv; priv = E_CLIENT_COMBO_BOX_GET_PRIVATE (object); g_clear_object (&priv->client_cache); /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_client_combo_box_parent_class)->dispose (object); } static void e_client_combo_box_class_init (EClientComboBoxClass *class) { GObjectClass *object_class; g_type_class_add_private (class, sizeof (EClientComboBoxPrivate)); object_class = G_OBJECT_CLASS (class); object_class->set_property = client_combo_box_set_property; object_class->get_property = client_combo_box_get_property; object_class->dispose = client_combo_box_dispose; /** * EClientComboBox:client-cache: * * Cache of shared #EClient instances. **/ /* XXX Don't use G_PARAM_CONSTRUCT_ONLY here. We need to allow * for this class to be instantiated by a GtkBuilder with no * special construct parameters, and then subsequently give * it an EClientCache. */ g_object_class_install_property ( object_class, PROP_CLIENT_CACHE, g_param_spec_object ( "client-cache", "Client Cache", "Cache of shared EClient instances", E_TYPE_CLIENT_CACHE, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } static void e_client_combo_box_init (EClientComboBox *combo_box) { combo_box->priv = E_CLIENT_COMBO_BOX_GET_PRIVATE (combo_box); } /** * e_client_combo_box_new: * @client_cache: an #EClientCache * @extension_name: the name of an #ESource extension * * Creates a new #EClientComboBox widget that lets the user pick an #ESource * from the provided @client_cache. The displayed sources are restricted to * those which have an @extension_name extension. * * Returns: a new #EClientComboBox **/ GtkWidget * e_client_combo_box_new (EClientCache *client_cache, const gchar *extension_name) { ESourceRegistry *registry; GtkWidget *widget; g_return_val_if_fail (E_IS_CLIENT_CACHE (client_cache), NULL); g_return_val_if_fail (extension_name != NULL, NULL); registry = e_client_cache_ref_registry (client_cache); widget = g_object_new ( E_TYPE_CLIENT_COMBO_BOX, "client-cache", client_cache, "extension-name", extension_name, "registry", registry, NULL); g_object_unref (registry); return widget; } /** * e_client_combo_box_ref_client_cache: * @combo_box: an #EClientComboBox * * Returns the #EClientCache passed to e_client_combo_box_new(). * * The returned #EClientCache is referenced for thread-safety and must be * unreferenced with g_object_unref() when finished with it. * * Returns: an #EClientCache **/ EClientCache * e_client_combo_box_ref_client_cache (EClientComboBox *combo_box) { g_return_val_if_fail (E_IS_CLIENT_COMBO_BOX (combo_box), NULL); return g_object_ref (combo_box->priv->client_cache); } /** * e_client_combo_box_set_client_cache: * @combo_box: an #EClientComboBox * * Simultaneously sets the #EClientComboBox:client-cache and * #ESourceComboBox:registry properties. * * This function is intended for cases where @combo_box is instantiated * by a #GtkBuilder and has to be given an #EClientCache after it is fully * constructed. **/ void e_client_combo_box_set_client_cache (EClientComboBox *combo_box, EClientCache *client_cache) { ESourceRegistry *registry = NULL; g_return_if_fail (E_IS_CLIENT_COMBO_BOX (combo_box)); if (combo_box->priv->client_cache == client_cache) return; if (client_cache != NULL) { g_return_if_fail (E_IS_CLIENT_CACHE (client_cache)); g_object_ref (client_cache); } if (combo_box->priv->client_cache != NULL) g_object_unref (combo_box->priv->client_cache); combo_box->priv->client_cache = client_cache; if (client_cache != NULL) registry = e_client_cache_ref_registry (client_cache); e_source_combo_box_set_registry ( E_SOURCE_COMBO_BOX (combo_box), registry); g_clear_object (®istry); g_object_notify (G_OBJECT (combo_box), "client-cache"); } /** * e_client_combo_box_get_client_sync: * @combo_box: an #EClientComboBox * @source: an #ESource * @cancellable: optional #GCancellable object, or %NULL * @error: return location for a #GError, or %NULL * * Obtains a shared #EClient instance for @source, or else creates a new * #EClient instance to be shared. * * The #ESourceComboBox:extension-name property determines the type of * #EClient to obtain. See e_client_cache_get_client_sync() for a list * of valid extension names. * * If a request for the same @source and #ESourceComboBox:extension-name * is already in progress when this function is called, this request will * "piggyback" on the in-progress request such that they will both succeed * or fail simultaneously. * * Unreference the returned #EClient with g_object_unref() when finished * with it. If an error occurs, the function will set @error and return * %NULL. * * Returns: an #EClient, or %NULL **/ EClient * e_client_combo_box_get_client_sync (EClientComboBox *combo_box, ESource *source, GCancellable *cancellable, GError **error) { EAsyncClosure *closure; GAsyncResult *result; EClient *client; g_return_val_if_fail (E_IS_CLIENT_COMBO_BOX (combo_box), NULL); g_return_val_if_fail (E_IS_SOURCE (source), NULL); closure = e_async_closure_new (); e_client_combo_box_get_client ( combo_box, source, cancellable, e_async_closure_callback, closure); result = e_async_closure_wait (closure); client = e_client_combo_box_get_client_finish ( combo_box, result, error); e_async_closure_free (closure); return client; } /* Helper for e_client_combo_box_get_client() */ static void client_combo_box_get_client_done_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { EClient *client; GSimpleAsyncResult *simple; GError *error = NULL; simple = G_SIMPLE_ASYNC_RESULT (user_data); client = e_client_cache_get_client_finish ( E_CLIENT_CACHE (source_object), result, &error); /* Sanity check. */ g_return_if_fail ( ((client != NULL) && (error == NULL)) || ((client == NULL) && (error != NULL))); if (client != NULL) { g_simple_async_result_set_op_res_gpointer ( simple, g_object_ref (client), (GDestroyNotify) g_object_unref); g_object_unref (client); } if (error != NULL) g_simple_async_result_take_error (simple, error); g_simple_async_result_complete (simple); g_object_unref (simple); } /** * e_client_combo_box_get_client: * @combo_box: an #EClientComboBox * @source: an #ESource * @cancellable: optional #GCancellable object, or %NULL * @callback: a #GAsyncReadyCallback to call when the request is satisfied * @user_data: data to pass to the callback function * * Asynchronously obtains a shared #EClient instance for @source, or else * creates a new #EClient instance to be shared. * * The #ESourceComboBox:extension-name property determines the type of * #EClient to obtain. See e_client_cache_get_client_sync() for a list * of valid extension names. * * If a request for the same @source and #ESourceComboBox:extension-name * is already in progress when this function is called, this request will * "piggyback" on the in-progress request such that they will both succeed * or fail simultaneously. * * When the operation is finished, @callback will be called. You can * then call e_client_combo_box_get_client_finish() to get the result of * the operation. **/ void e_client_combo_box_get_client (EClientComboBox *combo_box, ESource *source, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { EClientCache *client_cache; GSimpleAsyncResult *simple; const gchar *extension_name; g_return_if_fail (E_IS_CLIENT_COMBO_BOX (combo_box)); g_return_if_fail (E_IS_SOURCE (source)); simple = g_simple_async_result_new ( G_OBJECT (combo_box), callback, user_data, e_client_combo_box_get_client); g_simple_async_result_set_check_cancellable (simple, cancellable); extension_name = e_source_combo_box_get_extension_name ( E_SOURCE_COMBO_BOX (combo_box)); client_cache = e_client_combo_box_ref_client_cache (combo_box); e_client_cache_get_client ( client_cache, source, extension_name, cancellable, client_combo_box_get_client_done_cb, g_object_ref (simple)); g_object_unref (client_cache); g_object_unref (simple); } /** * e_client_combo_box_get_client_finish: * @combo_box: an #EClientComboBox * @result: a #GAsyncResult * @error: return location for a #GError, or %NULL * * Finishes the operation started with e_client_combo_box_get_client(). * * Unreference the returned #EClient with g_object_unref() when finished * with it. If an error occurred, the function will set @error and return * %NULL. * * Returns: an #EClient, or %NULL **/ EClient * e_client_combo_box_get_client_finish (EClientComboBox *combo_box, GAsyncResult *result, GError **error) { GSimpleAsyncResult *simple; EClient *client; g_return_val_if_fail ( g_simple_async_result_is_valid ( result, G_OBJECT (combo_box), e_client_combo_box_get_client), NULL); simple = G_SIMPLE_ASYNC_RESULT (result); client = g_simple_async_result_get_op_res_gpointer (simple); if (g_simple_async_result_propagate_error (simple, error)) return NULL; g_return_val_if_fail (client != NULL, NULL); return g_object_ref (client); } /** * e_client_combo_box_ref_cached_client: * @combo_box: an #EClientComboBox * @source: an #ESource * * Returns a shared #EClient instance for @source and the value of * #ESourceComboBox:extension-name if such an instance is already cached, * or else %NULL. This function does not create a new #EClient instance, * and therefore does not block. * * The returned #EClient is referenced for thread-safety and must be * unreferenced with g_object_unref() when finished with it. * * Returns: an #EClient, or %NULL **/ EClient * e_client_combo_box_ref_cached_client (EClientComboBox *combo_box, ESource *source) { EClient *client; EClientCache *client_cache; const gchar *extension_name; g_return_val_if_fail (E_IS_CLIENT_COMBO_BOX (combo_box), NULL); g_return_val_if_fail (E_IS_SOURCE (source), NULL); extension_name = e_source_combo_box_get_extension_name ( E_SOURCE_COMBO_BOX (combo_box)); client_cache = e_client_combo_box_ref_client_cache (combo_box); client = e_client_cache_ref_cached_client ( client_cache, source, extension_name); g_object_unref (client_cache); return client; } =v6.0.0-beta.1&id=60c19d22eb79aed3084ede5d4a0725235376c6b3'>Add initial Sphinx docs directory, added docs/_build/ folder to .gitignoreholgerd772017-08-305-0/+249 |/ / / / * | | | Merge pull request #288 from ethereum/fillchain-stRandomYoichi Hirai2017-08-301-54/+40 |\ \ \ \ | |/ / / |/| | | | * | | --fillchain BlockchainTests/GeneralStateTests/stRandom/randomStatetest642_d0g...Yoichi Hirai2017-08-301-54/+40 |/ / / * | | Merge pull request #285 from ethereum/log-as-hashYoichi Hirai2017-08-291-1509/+128 |\ \ \ | * | | Replace the remaining log arrays with log hashesYoichi Hirai2017-08-291-1509/+128 * | | | Merge pull request #283 from ethereum/returndatasize_after_staticcallYoichi Hirai2017-08-298-0/+772 |\ \ \ \ | |/ / / |/| | | | * | | add 'returndatacopy_after_successful_delegatecall' state testJared Wasinger2017-08-292-0/+193 | * | | add 'returndatacopy_after_successful_callcode' state testJared Wasinger2017-08-292-0/+193 | * | | add 'returndatasize_after_successful_delegatecall' state testJared Wasinger2017-08-292-0/+193 | * | | add 'returndatasize_after_successful_staticcall' state testJared Wasinger2017-08-292-0/+193 |/ / / * | | Merge pull request #282 from ethereum/precompiled-failure-means-balance-revertYoichi Hirai2017-08-291-3/+3 |\ \ \ | * | | This change is a part of the fix to https://github.com/ethereum/cpp-ethereum/...Yoichi Hirai2017-08-281-3/+3 |/ / / * / / add randomTest642 that fails on geth. a call to precompiled 007Dimitry2017-08-283-0/+896 |/ / * | Merge pull request #279 from ethereum/filled-hive-testsYoichi Hirai2017-08-283036-141382/+244798 |\ \ | * | Translate GeneralStateTests into BlockahtinTests/GeneralStateTestsYoichi Hirai2017-08-283036-141382/+244798 * | | Merge pull request #278 from ethereum/returndatasize_after_callcodeYoichi Hirai2017-08-282-0/+192 |\ \ \ | |/ / |/| | | * | add state test 'returndatasize_after_callcode'Jared Wasinger2017-08-282-0/+192 |/ / * | Merge pull request #268 from ethereum/bc-schemaYoichi Hirai2017-08-265-4/+507 |\ \ | * | add blockchain test linting to travisJared Wasinger2017-08-265-4/+507 |/ / * | Merge pull request #275 from ethereum/bc-schema-test-fixesYoichi Hirai2017-08-264-1549/+1532 |\ \ | |/ |/| | * fix tests that don't conform to blockchain test schemaJared Wasinger2017-08-264-1549/+1532 |/ * Merge pull request #273 from ethereum/vmIO-fixYoichi Hirai2017-08-252-146/+145 |\ | * Fix the filler and fill vmIOandFlowOperationsTestYoichi Hirai2017-08-242-146/+145 * | Merge pull request #274 from ethereum/log-new-formatYoichi Hirai2017-08-253-76969/+38570 |\ \ | |/ |/| | * Replace more logs with log hashesYoichi Hirai2017-08-242-76924/+38463 | * Replace logs with log hashesYoichi Hirai2017-08-241-45/+107 |/ * Merge pull request #271 from ethereum/address-collision-failsYoichi Hirai2017-08-246-112/+22 |\ | * Changes for EIP-684Yoichi Hirai2017-08-246-112/+22 |/ * Merge pull request #267 from ethereum/some-vm-test-failuresYoichi Hirai2017-08-2419-1468/+3457 |\ | * Replace logs with hashesYoichi Hirai2017-08-238-17/+9 | * Fix some VMTest filling failuresYoichi Hirai2017-08-2311-1451/+3448 |/ * Merge pull request #269 from ethereum/eip649Yoichi Hirai2017-08-23224-36522/+36848 |\ | * Fix uncleHeaderAt2ByzantiumFiller with a correct state root hashYoichi Hirai2017-08-232-3/+705 | * Fix uncleBloomNot0_2 with the expected state root hashYoichi Hirai2017-08-232-97/+148 | * Fix futureUncleTimestampDifficultyDrop2Yoichi Hirai2017-08-232-98/+149 | * Fill more testsYoichi Hirai2017-08-2247-1338/+1551 | * Fill more testsYoichi Hirai2017-08-2247-1695/+1482 | * Fill more tests on eip649 branchYoichi Hirai2017-08-2221-788/+762 | * Fill in more testsYoichi Hirai2017-08-2216-1369/+917 | * Refill more straightforward BlockchainTestsYoichi Hirai2017-08-2278-6787/+6787 | * Refill straightforward casesYoichi Hirai2017-08-2272-26077/+26077 * | Merge pull request #266 from ethereum/0x-fieldswinsvega2017-08-234-1563/+1563 |\ \ | * | Refilled tests again so that 0x is in front of byte sequencesYoichi Hirai2017-08-224-1563/+1563 * | | Merge pull request #213 from jwasinger/issue-204Yoichi Hirai2017-08-234-1/+688 |\ \ \ | * | | add storage and code restrictions to json schemacdetrio2017-08-082-3/+25 | * | | replace Metropolis with Byzantium and Constantinople in state test schemacdetrio2017-08-081-1/+4 | * | | add schema for state test fillerscdetrio2017-08-082-0/+258 | * | | use more type definitions in schemacdetrio2017-08-081-116/+214 | * | | validate.js takes schema file as argumentcdetrio2017-08-082-2/+4 | * | | improve type checking.Jared Wasinger2017-08-081-148/+190 | * | | remove es6 syntax from validation script.Jared Wasinger2017-08-081-1/+1 | * | | make travis use node8Jared Wasinger2017-08-081-1/+1 | * | | make log ordering consistentJared Wasinger2017-08-081-0/+11 | * | | add ECDSA parameters r, s, v. Make sure certain fields are marked as require...Jared Wasinger2017-08-081-8/+25 | * | | make error output more informative. Make schema more comprehensive. Add exi...Jared Wasinger2017-08-083-38/+81 | * | | fix process errorJared Wasinger2017-08-081-1/+0 | * | | format code. Remove unused python codeJared Wasinger2017-08-083-132/+105 | * | | use JS for json schema validation because the Node 'jsonschema' library is th...Jared Wasinger2017-08-083-8/+15 | * | | add schema validation with Travis integration.Jared Wasinger2017-08-084-20/+42 | * | | add "explanation" field. Reduce number of schema errorsJared Wasinger2017-08-084-2/+7 | * | | modify validation script to run against all test cases under GeneralStateTestsJared Wasinger2017-08-082-27/+9 | * | | add working schema outlineJared Wasinger2017-08-083-62/+194 | * | | add JSON schema skeleton for #204Jared Wasinger2017-08-081-0/+71 * | | | Merge pull request #253 from cdetrio/fix-data-0xYoichi Hirai2017-08-2334-138/+138 |\ \ \ \ | |_|/ / |/| | | | * | | add 0x prefix to state test transaction datacdetrio2017-08-0834-138/+138 | |/ / * | | Merge pull request #265 from ethereum/refill-wallet-testswinsvega2017-08-224-1727/+1727 |\ \ \ | |_|/ |/| | | * | Refill bcWalletTestYoichi Hirai2017-08-224-1727/+1727 |/ / * | refill opcodes test with logsDimitry2017-08-221-469/+235 * | Merge pull request #264 from ethereum/refill-empty-accountwinsvega2017-08-224-2315/+2287 |\ \ | * | Refill wallet testsYoichi Hirai2017-08-224-1984/+1963 | * | Refill the test wallet2outOf3txsRevoke.jsonYoichi Hirai2017-08-221-595/+588 * | | Merge pull request #263 from ethereum/logswinsvega2017-08-212726-89623/+23638 |\ \ \ | * | | make all logs hexDimitry2017-08-212193-81494/+17073 | * | | remove old fields from random testsDimitry2017-08-211081-8677/+7113 |/ / / * | | Merge pull request #261 from jwasinger/masterwinsvega2017-08-213-1/+2523 |\ \ \ | * | | check for all possible invalid opcodes.Jared Wasinger2017-08-178-640/+2477 | * | | fix tests to conform to schemaJared Wasinger2017-08-175-7/+7 | * | | add SLOADBYTESJared Wasinger2017-08-173-1/+189 | * | | add badOpcode tests for SLOADBYTES and SSIZEJared Wasinger2017-08-175-3/+313 | * | | add badOpcode state test for SSIZEJared Wasinger2017-08-172-0/+187 * | | | Merge pull request #254 from cdetrio/fix-filler-storagewinsvega2017-08-2118-26/+26 |\ \ \ \ | |_|/ / |/| | | | * | | use hex for storage keys and values in state test fillerscdetrio2017-08-0818-26/+26 | | |/ | |/| * | | Merge pull request #262 from ethereum/eip96-to-constantinopleYoichi Hirai2017-08-17221-36812/+35337 |\ \ \ | |_|/ |/| | | * | Fix more BlockchainTestsYoichi Hirai2017-08-1719-2908/+2826 | * | fill BlockchainTests after delaying EIP96 to ConstantinopleYoichi Hirai2017-08-16206-34380/+32987 |/ / * | update comments in dao transition testsDimitry2017-08-157-472/+472 * | Merge pull request #260 from ethereum/bigger-memory-allocwinsvega2017-08-154-133/+133 |\ \ | * | Fix the modexpFiller about large base length and large exp lengthYoichi Hirai2017-08-144-133/+133 |/ / * | fix test name zeroSigTransactionCreateDimitry2017-08-144-5/+787 * | Merge pull request #258 from cdetrio/returndata-caseswinsvega2017-08-1110-0/+891 |\ \ | * | more returndata test casescdetrio2017-08-1110-0/+891 * | | Update and rename zeroSigTransacrionCreate.json to zeroSigTransactionCreate.jsonwinsvega2017-08-111-2/+2 |/ / * | Merge pull request #255 from ethereum/revert-returndatacopywinsvega2017-08-093-0/+953 |\ \ | |/ |/| | * Add a test case that RETURNDATACOPYs REVERTed dataYoichi Hirai2017-08-083-0/+953 |/ * Merge pull request #250 from cdetrio/filler-valid-jsonYoichi Hirai2017-08-0721-554/+554 |\ | * fix invalid json fillerscdetrio2017-08-0621-554/+554 * | Merge pull request #248 from ethereum/odd-length-hex-in-vm-fillerwinsvega2017-08-064-89/+439 |\ \ | * | Fix some formatting issues in VMTest fillersYoichi Hirai2017-08-054-89/+439 | |/ * | Merge pull request #246 from ethereum/filled-vm-test-no-expectwinsvega2017-08-063-68/+0 |\ \ | * | Remove "expect" sections from VM testsYoichi Hirai2017-08-053-68/+0 | |/ * | Merge pull request #251 from ethereum/hivetestswinsvega2017-08-062851-164758/+619483 |\ \ | |/ |/| | * Hive tests with ByzantineDimitry2017-08-062851-164758/+619483 |/ * Merge pull request #245 from ethereum/blockhashtestYoichi Hirai2017-08-042-102/+155 |\ | * blockhash test on Byzantine transitionDimitry2017-08-042-102/+155 * | Merge pull request #244 from ethereum/clear-storage-after-initwinsvega2017-08-043-80/+226 |\ \ | |/ |/| | * Fix the filler as wellYoichi Hirai2017-08-041-1/+5 | * Change tests so that the storage is cleared before, not after contract initia...Yoichi Hirai2017-08-042-79/+221 |/ * Merge pull request #241 from ethereum/metrosplitwinsvega2017-08-043205-75436/+304768 |\ | * Transition tests with ByzantiumDimitry2017-08-0315-3448/+865 | * split metropolisDimitry2017-08-033191-71988/+303903 |/ * Merge pull request #214 from ethereum/add-commentwinsvega2017-08-011-0/+1 |\ | * Add an explanationYoichi Hirai2017-07-061-0/+1 * | Merge pull request #238 from ethereum/updateHivewinsvega2017-08-016932-1764363/+2404939 |\ \ | * | update general testsDimitry2017-08-01