static void cd_srcdir (const char *argv0) { gchar *dir = g_path_get_dirname (argv0); g_warn_if_fail (g_chdir (dir) == 0); g_free (dir); }
void ibus_connection_set_connection (IBusConnection *connection, DBusConnection *dbus_connection, gboolean shared) { gboolean result; IBusConnectionPrivate *priv; g_assert (IBUS_IS_CONNECTION (connection)); g_assert (dbus_connection != NULL); g_assert (dbus_connection_get_is_connected (dbus_connection)); priv = IBUS_CONNECTION_GET_PRIVATE (connection); g_assert (priv->connection == NULL); priv->connection = dbus_connection_ref (dbus_connection); priv->shared = shared; dbus_connection_set_data (priv->connection, _get_slot(), connection, NULL); dbus_connection_set_unix_user_function (priv->connection, (DBusAllowUnixUserFunction) _connection_allow_unix_user_cb, connection, NULL); result = dbus_connection_add_filter (priv->connection, (DBusHandleMessageFunction) _connection_handle_message_cb, connection, NULL); ibus_dbus_connection_setup (priv->connection); g_warn_if_fail (result); }
/** * g_bus_unwatch_name: * @watcher_id: An identifier obtained from g_bus_watch_name() * * Stops watching a name. * * Since: 2.26 */ void g_bus_unwatch_name (guint watcher_id) { Client *client; g_return_if_fail (watcher_id > 0); client = NULL; G_LOCK (lock); if (watcher_id == 0 || map_id_to_client == NULL || (client = g_hash_table_lookup (map_id_to_client, GUINT_TO_POINTER (watcher_id))) == NULL) { g_warning ("Invalid id %d passed to g_bus_unwatch_name()", watcher_id); goto out; } client->cancelled = TRUE; g_warn_if_fail (g_hash_table_remove (map_id_to_client, GUINT_TO_POINTER (watcher_id))); out: G_UNLOCK (lock); /* do callback without holding lock */ if (client != NULL) { client_unref (client); } }
static void registration_data_unexport_interface (RegistrationData *data, GDBusInterfaceSkeleton *interface_skeleton) { GDBusInterfaceInfo *info; GDBusInterfaceSkeleton *iface; info = g_dbus_interface_skeleton_get_info (interface_skeleton); iface = g_hash_table_lookup (data->map_iface_name_to_iface, info->name); g_assert (iface != NULL); if (data->manager->priv->connection != NULL) g_dbus_interface_skeleton_unexport (iface); g_warn_if_fail (g_hash_table_remove (data->map_iface_name_to_iface, info->name)); /* if we are already exported, then... */ if (data->exported) { const gchar *interfaces[2]; /* emit InterfacesRemoved on the ObjectManager object */ interfaces[0] = info->name; interfaces[1] = NULL; g_dbus_object_manager_server_emit_interfaces_removed (data->manager, data, interfaces); } }
static void ibus_connection_destroy (IBusConnection *connection) { IBusConnectionPrivate *priv; priv = IBUS_CONNECTION_GET_PRIVATE (connection); if (priv->connection) { dbus_connection_remove_filter (priv->connection, (DBusHandleMessageFunction) _connection_handle_message_cb, connection); } do { if (!priv->shared && priv->connection) { dbus_connection_close (priv->connection); dbus_connection_unref (priv->connection); priv->connection = NULL; break; } if (priv->shared && priv->connection) { g_warn_if_fail (_connections != NULL); if (_connections != NULL) { g_hash_table_remove (_connections, priv->connection); } dbus_connection_unref (priv->connection); priv->connection = NULL; break; } } while (0); IBUS_OBJECT_CLASS (ibus_connection_parent_class)->destroy (IBUS_OBJECT (connection)); }
static void xviewer_reload_plugin_activate (XviewerWindowActivatable *activatable) { GtkUIManager *manager; XviewerReloadPlugin *plugin = XVIEWER_RELOAD_PLUGIN (activatable); xviewer_debug (DEBUG_PLUGINS); manager = xviewer_window_get_ui_manager (plugin->window); plugin->ui_action_group = gtk_action_group_new ("XviewerReloadPluginActions"); gtk_action_group_set_translation_domain (plugin->ui_action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (plugin->ui_action_group, action_entries, G_N_ELEMENTS (action_entries), plugin->window); gtk_ui_manager_insert_action_group (manager, plugin->ui_action_group, -1); plugin->ui_id = gtk_ui_manager_add_ui_from_string (manager, ui_definition, -1, NULL); g_warn_if_fail (plugin->ui_id != 0); }
static void _name_owner_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { NMVpnService *service = NM_VPN_SERVICE (user_data); NMVpnServicePrivate *priv = NM_VPN_SERVICE_GET_PRIVATE (service); gboolean success; char *owner; owner = g_dbus_proxy_get_name_owner (G_DBUS_PROXY (object)); /* Service changed, no need to wait for the timeout any longer */ if (priv->start_timeout) { g_source_remove (priv->start_timeout); priv->start_timeout = 0; } if (owner && !priv->service_running) { /* service appeared */ priv->service_running = TRUE; nm_log_info (LOGD_VPN, "VPN service '%s' appeared; activating connections", nm_vpn_plugin_info_get_name (priv->plugin_info)); /* Expect success because the VPN service has already appeared */ success = start_active_vpn (service, NULL); g_warn_if_fail (success); } else if (!owner && priv->service_running) { /* service went away */ priv->service_running = FALSE; nm_log_info (LOGD_VPN, "VPN service '%s' disappeared", nm_vpn_plugin_info_get_name (priv->plugin_info)); nm_vpn_service_stop_connections (service, FALSE, NM_VPN_CONNECTION_STATE_REASON_SERVICE_STOPPED); } g_free (owner); }
static FormHistoryPriv* formhistory_new (const gchar* config_dir) { gchar* filename; GError* error = NULL; FormHistoryPriv* priv = formhistory_private_new (); priv->master_password = NULL; priv->master_password_canceled = 0; formhistory_construct_popup_gui (priv); if (config_dir == NULL) { priv->db = NULL; return priv; } filename = g_build_filename (config_dir, "forms.db", NULL); priv->database = midori_database_new (filename, &error); g_free (filename); if (error != NULL) { g_critical ("%s", error->message); g_error_free (error); priv->db = NULL; return priv; } priv->db = midori_database_get_db (MIDORI_DATABASE (priv->database)); g_warn_if_fail (priv->db != NULL); return priv; }
/** * nm_wimax_nsp_connection_valid: * @nsp: an #NMWimaxNsp to validate @connection against * @connection: an #NMConnection to validate against @nsp * * Validates a given connection against a given WiMAX NSP to ensure that the * connection may be activated with that NSP. The connection must match the * @nsp's network name and other attributes. * * Returns: %TRUE if the connection may be activated with this WiMAX NSP, * %FALSE if it cannot be. **/ gboolean nm_wimax_nsp_connection_valid (NMWimaxNsp *nsp, NMConnection *connection) { NMSettingConnection *s_con; NMSettingWimax *s_wimax; const char *ctype; const char *nsp_name; const char *setting_name; s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); ctype = nm_setting_connection_get_connection_type (s_con); if (strcmp (ctype, NM_SETTING_WIMAX_SETTING_NAME) != 0) return FALSE; s_wimax = nm_connection_get_setting_wimax (connection); if (!s_wimax) return FALSE; setting_name = nm_setting_wimax_get_network_name (s_wimax); if (!setting_name) return FALSE; nsp_name = nm_wimax_nsp_get_name (nsp); g_warn_if_fail (nsp_name != NULL); if (g_strcmp0 (nsp_name, setting_name) != 0) return FALSE; return TRUE; }
/** * g_dbus_address_get_stream_finish: * @res: A #GAsyncResult obtained from the GAsyncReadyCallback passed to g_dbus_address_get_stream(). * @out_guid: %NULL or return location to store the GUID extracted from @address, if any. * @error: Return location for error or %NULL. * * Finishes an operation started with g_dbus_address_get_stream(). * * Returns: A #GIOStream or %NULL if @error is set. * * Since: 2.26 */ GIOStream * g_dbus_address_get_stream_finish (GAsyncResult *res, gchar **out_guid, GError **error) { GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res); GetStreamData *data; GIOStream *ret; g_return_val_if_fail (G_IS_ASYNC_RESULT (res), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); g_warn_if_fail (g_simple_async_result_get_source_tag (simple) == g_dbus_address_get_stream); ret = NULL; data = g_simple_async_result_get_op_res_gpointer (simple); if (g_simple_async_result_propagate_error (simple, error)) goto out; ret = g_object_ref (data->stream); if (out_guid != NULL) *out_guid = g_strdup (data->guid); out: return ret; }
static PriorityMap * priority_map_new_from_str (NMVlanPriorityMap map, const char *str) { PriorityMap *p = NULL; gchar **t = NULL; guint32 len; guint64 from, to; g_return_val_if_fail (str && str[0], NULL); t = g_strsplit (str, ":", 0); len = g_strv_length (t); if (len == 2) { from = g_ascii_strtoull (t[0], NULL, 10); to = g_ascii_strtoull (t[1], NULL, 10); if ((from <= get_max_prio (map, TRUE)) && (to <= get_max_prio (map, FALSE))) { p = g_malloc0 (sizeof (PriorityMap)); p->from = from; p->to = to; } } else { /* Warn */ g_warn_if_fail (len == 2); } g_strfreev (t); return p; }
static void gst_net_client_internal_clock_finalize (GObject * object) { GstNetClientInternalClock *self = GST_NET_CLIENT_INTERNAL_CLOCK (object); if (self->thread) { gst_net_client_internal_clock_stop (self); } g_free (self->address); self->address = NULL; if (self->servaddr != NULL) { g_object_unref (self->servaddr); self->servaddr = NULL; } if (self->socket != NULL) { if (!g_socket_close (self->socket, NULL)) GST_ERROR_OBJECT (self, "Failed to close socket"); g_object_unref (self->socket); self->socket = NULL; } g_warn_if_fail (self->busses == NULL); G_OBJECT_CLASS (gst_net_client_internal_clock_parent_class)->finalize (object); }
/** * g_dbus_error_register_error_domain: * @error_domain_quark_name: The error domain name. * @quark_volatile: A pointer where to store the #GQuark. * @entries: A pointer to @num_entries #GDBusErrorEntry struct items. * @num_entries: Number of items to register. * * Helper function for associating a #GError error domain with D-Bus error names. * * Since: 2.26 */ void g_dbus_error_register_error_domain (const gchar *error_domain_quark_name, volatile gsize *quark_volatile, const GDBusErrorEntry *entries, guint num_entries) { g_return_if_fail (error_domain_quark_name != NULL); g_return_if_fail (quark_volatile != NULL); g_return_if_fail (entries != NULL); g_return_if_fail (num_entries > 0); if (g_once_init_enter (quark_volatile)) { guint n; GQuark quark; quark = g_quark_from_static_string (error_domain_quark_name); for (n = 0; n < num_entries; n++) { g_warn_if_fail (g_dbus_error_register_error (quark, entries[n].error_code, entries[n].dbus_error_name)); } g_once_init_leave (quark_volatile, quark); } }
int SpiceController::Connect(const int nRetries) { int rc = -1; int sleep_time = 0; // try to connect for specified count for (int i = 0; rc != 0 && i < nRetries; ++i) { rc = Connect(); g_usleep(sleep_time * G_USEC_PER_SEC); ++sleep_time; } if (rc != 0) { g_warning("error connecting"); g_assert(m_pipe == NULL); } if (!CheckPipe()) { g_warning("Pipe validation failure"); g_warn_if_fail(m_pipe == NULL); } if (m_pipe == NULL) { g_warning("failed to create pipe"); #ifdef XP_WIN rc = MAKE_HRESULT(1, FACILITY_CREATE_RED_PIPE, GetLastError()); #endif this->StopClient(); } return rc; }
static void save_snapshot_get_message_cb (EMsgComposer *composer, GAsyncResult *result, GSimpleAsyncResult *simple) { SaveContext *context; CamelMimeMessage *message; GTask *task; GError *local_error = NULL; context = g_simple_async_result_get_op_res_gpointer (simple); message = e_msg_composer_get_message_draft_finish ( composer, result, &local_error); if (local_error != NULL) { g_warn_if_fail (message == NULL); g_simple_async_result_take_error (simple, local_error); g_simple_async_result_complete (simple); g_object_unref (simple); return; } g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message)); task = g_task_new (message, context->cancellable, (GAsyncReadyCallback) save_snapshot_splice_cb, simple); g_task_set_task_data (task, g_object_ref (context->output_stream), g_object_unref); g_task_run_in_thread (task, write_message_to_stream_thread); g_object_unref (task); g_object_unref (message); }
static GstPad * gst_dtls_enc_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * name, const GstCaps * caps) { GstPad *sink; gboolean ret; GST_DEBUG_OBJECT (element, "sink pad requested"); g_return_val_if_fail (templ->direction == GST_PAD_SINK, NULL); sink = gst_pad_new_from_template (templ, name); g_return_val_if_fail (sink, NULL); if (caps) { g_object_set (sink, "caps", caps, NULL); } gst_pad_set_chain_function (sink, GST_DEBUG_FUNCPTR (sink_chain)); ret = gst_pad_set_active (sink, TRUE); g_warn_if_fail (ret); gst_element_add_pad (element, sink); return sink; }
static gboolean smartcard_monitor_dispatch(VEvent *event, gpointer user_data) { g_return_val_if_fail(event != NULL, TRUE); SpiceSmartcardManager *manager = SPICE_SMARTCARD_MANAGER(user_data); switch (event->type) { case VEVENT_READER_INSERT: if (spice_smartcard_reader_is_software((SpiceSmartcardReader*)event->reader)) { g_warn_if_fail(manager->priv->software_reader == NULL); manager->priv->software_reader = vreader_reference(event->reader); } SPICE_DEBUG("smartcard: reader-added"); g_signal_emit(G_OBJECT(user_data), signals[SPICE_SMARTCARD_MANAGER_READER_ADDED], 0, event->reader); break; case VEVENT_READER_REMOVE: if (spice_smartcard_reader_is_software((SpiceSmartcardReader*)event->reader)) { g_warn_if_fail(manager->priv->software_reader != NULL); vreader_free(manager->priv->software_reader); manager->priv->software_reader = NULL; } SPICE_DEBUG("smartcard: reader-removed"); g_signal_emit(G_OBJECT(user_data), signals[SPICE_SMARTCARD_MANAGER_READER_REMOVED], 0, event->reader); break; case VEVENT_CARD_INSERT: SPICE_DEBUG("smartcard: card-inserted"); g_signal_emit(G_OBJECT(user_data), signals[SPICE_SMARTCARD_MANAGER_CARD_INSERTED], 0, event->reader); break; case VEVENT_CARD_REMOVE: SPICE_DEBUG("smartcard: card-removed"); g_signal_emit(G_OBJECT(user_data), signals[SPICE_SMARTCARD_MANAGER_CARD_REMOVED], 0, event->reader); break; case VEVENT_LAST: break; } return TRUE; }
/** * soup_uri_uses_default_port: * @uri: a #SoupURI * * Tests if @uri uses the default port for its scheme. (Eg, 80 for * http.) (This only works for http, https and ftp; libsoup does not know * the default ports of other protocols.) * * Return value: %TRUE or %FALSE **/ gboolean soup_uri_uses_default_port (SoupURI *uri) { g_return_val_if_fail (uri != NULL, FALSE); g_warn_if_fail (SOUP_URI_IS_VALID (uri)); return uri->port == soup_scheme_default_port (uri->scheme); }
static gboolean update_secret_hash (NMSetting *setting, GHashTable *secrets, GError **error) { NMSettingVPNPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (setting); GHashTableIter iter; const char *name, *value; g_return_val_if_fail (secrets != NULL, FALSE); /* Make sure the items are valid */ g_hash_table_iter_init (&iter, secrets); while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &value)) { if (!name || !strlen (name)) { g_set_error_literal (error, NM_SETTING_ERROR, NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, "Secret name was empty"); return FALSE; } if (!value || !strlen (value)) { g_set_error (error, NM_SETTING_ERROR, NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH, "Secret %s value was empty", name); return FALSE; } } /* Now add the items to the settings' secrets list */ g_hash_table_iter_init (&iter, secrets); while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &value)) { if (value == NULL) { g_warn_if_fail (value != NULL); continue; } if (strlen (value) == 0) { g_warn_if_fail (strlen (value) > 0); continue; } g_hash_table_insert (priv->secrets, g_strdup (name), g_strdup (value)); } return TRUE; }
static void set_nas_iface (NMDeviceAdsl *self, int idx, const char *name) { NMDeviceAdslPrivate *priv = NM_DEVICE_ADSL_GET_PRIVATE (self); g_return_if_fail (name != NULL); g_warn_if_fail (priv->nas_ifindex <= 0); priv->nas_ifindex = idx > 0 ? idx : nm_platform_link_get_ifindex (name); g_warn_if_fail (priv->nas_ifindex > 0); g_warn_if_fail (priv->nas_ifname == NULL); priv->nas_ifname = g_strdup (name); /* Update NAS interface's MAC address */ nm_device_update_hw_address (NM_DEVICE (self)); }
/** * qmi_utils_write_string_to_buffer: * @buffer: a buffer. * @buffer_size: size of @buffer. * @length_prefix_size: size of the length prefix integer in bits. * @in: string to write. * * Writes a string to the buffer. * * If @length_prefix_size is greater than 0, a length prefix integer will be * included in the write operation. * * The user needs to make sure that the buffer has enough space for both the * whole string and the length prefix. * * Also note that both @buffer and @buffer_size get updated after the write. */ void qmi_utils_write_string_to_buffer (guint8 **buffer, guint16 *buffer_size, guint8 length_prefix_size, const gchar *in) { guint16 len; guint8 len_8; guint16 len_16; g_assert (in != NULL); g_assert (buffer != NULL); g_assert (buffer_size != NULL); g_assert (length_prefix_size == 0 || length_prefix_size == 8 || length_prefix_size == 16); len = (guint16) strlen (in); switch (length_prefix_size) { case 0: break; case 8: g_warn_if_fail (len <= G_MAXUINT8); len_8 = (guint8)len; qmi_utils_write_guint8_to_buffer (buffer, buffer_size, &len_8); break; case 16: g_warn_if_fail (len <= G_MAXUINT16); len_16 = (guint16)len; qmi_utils_write_guint16_to_buffer (buffer, buffer_size, QMI_ENDIAN_LITTLE, &len_16); break; default: g_assert_not_reached (); } memcpy (*buffer, in, len); *buffer = &((*buffer)[len]); *buffer_size = (*buffer_size) - len; }
static void try_update_version (NMShellWatcher *watcher) { NMShellWatcherPrivate *priv = watcher->priv; GVariant *v; char *version, *p; v = g_dbus_proxy_get_cached_property (priv->shell_proxy, "ShellVersion"); if (!v) { /* The shell has claimed the name, but not yet registered its interfaces... * (https://bugzilla.gnome.org/show_bug.cgi?id=673182). There's no way * to make GDBusProxy re-read the properties at this point, so we * have to destroy this proxy and try again. */ if (priv->signal_id) { g_signal_handler_disconnect (priv->shell_proxy, priv->signal_id); priv->signal_id = 0; } g_object_unref (priv->shell_proxy); priv->shell_proxy = NULL; priv->retry_timeout = g_timeout_add_seconds (2, retry_create_shell_proxy, watcher); return; } g_warn_if_fail (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)); version = g_variant_dup_string (v, NULL); if (version) { guint major, minor; major = strtoul (version, &p, 10); if (*p == '.') minor = strtoul (p + 1, NULL, 10); else minor = 0; g_warn_if_fail (major < 256); g_warn_if_fail (minor < 256); priv->shell_version = (major << 8) | minor; g_object_notify (G_OBJECT (watcher), "shell-version"); } g_variant_unref (v); }
char * ccnetrpc_transport_send (void *arg, const gchar *fcall_str, size_t fcall_len, size_t *ret_len) { CcnetrpcTransportParam *priv; CcnetClient *session, *new_session; g_warn_if_fail (arg != NULL && fcall_str != NULL); priv = (CcnetrpcTransportParam *)arg; if (priv->session != NULL) { /* Use single ccnet client as transport. */ return invoke_service (priv->session, priv->peer_id, priv->service, fcall_str, fcall_len, ret_len); } else { /* Use client pool as transport. */ session = ccnet_client_pool_get_client (priv->pool); if (!session) { g_warning ("[Sea RPC] Failed to get client from pool.\n"); *ret_len = 0; return NULL; } char *ret = invoke_service (session, priv->peer_id, priv->service, fcall_str, fcall_len, ret_len); if (ret != NULL) { ccnet_client_pool_return_client (priv->pool, session); return ret; } /* If we failed to send data through the ccnet client returned by * client pool, ccnet may have been restarted. * In this case, we create a new ccnet client and put it into * the client pool after use. */ g_message ("[Sea RPC] Ccnet disconnected. Connect again.\n"); new_session = create_new_client (session->config_dir); if (!new_session) { *ret_len = 0; return NULL; } g_object_unref (session); ret = invoke_service (new_session, priv->peer_id, priv->service, fcall_str, fcall_len, ret_len); if (ret != NULL) ccnet_client_pool_return_client (priv->pool, new_session); else g_object_unref (new_session); return ret; } }
/** * g_error_copy: * @error: a #GError * * Makes a copy of @error. * * Returns: a new #GError */ GError* g_error_copy (const GError *error) { GError *copy; g_return_val_if_fail (error != NULL, NULL); /* See g_error_new_valist for why these don't return */ g_warn_if_fail (error->domain != 0); g_warn_if_fail (error->message != NULL); copy = g_slice_new (GError); *copy = *error; copy->message = g_strdup (error->message); return copy; }
/** * gdk_app_launch_context_set_display: * @context: a #GdkAppLaunchContext * @display: a #GdkDisplay * * Sets the display on which applications will be launched when * using this context. See also gdk_app_launch_context_set_screen(). * * Since: 2.14 * * Deprecated: 3.0: Use gdk_display_get_app_launch_context() instead */ void gdk_app_launch_context_set_display (GdkAppLaunchContext *context, GdkDisplay *display) { g_return_if_fail (GDK_IS_APP_LAUNCH_CONTEXT (context)); g_return_if_fail (display == NULL || GDK_IS_DISPLAY (display)); g_warn_if_fail (display == NULL || display == context->display); }
void HttpRequest::Started (HttpResponse *response) { VERIFY_MAIN_THREAD; LOG_DOWNLOADER ("HttpRequest::Started ()\n"); g_warn_if_fail (response != NULL); g_warn_if_fail (this->response == NULL); if (this->response != NULL) this->response->unref (); this->response = response; if (this->response != NULL) this->response->ref (); if (HasHandlers (StartedEvent)) Emit (StartedEvent); }
static void mpd_entry_changed (GtkWidget *widget, gpointer user_data) { GtkWidget *dialog = GTK_WIDGET (user_data); GladeXML *xml = g_object_get_data (G_OBJECT (dialog), "xml"); GtkWidget *entry; guint32 minlen; gboolean valid = FALSE; const char *text, *text2 = NULL, *text3 = NULL; gboolean match23; g_return_if_fail (xml != NULL); entry = glade_xml_get_widget (xml, "code1_entry"); if (g_object_get_data (G_OBJECT (entry), "active")) { minlen = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (entry), "minlen")); text = gtk_entry_get_text (GTK_ENTRY (entry)); if (text && (strlen (text) < minlen)) goto done; } entry = glade_xml_get_widget (xml, "code2_entry"); if (g_object_get_data (G_OBJECT (entry), "active")) { minlen = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (entry), "minlen")); text2 = gtk_entry_get_text (GTK_ENTRY (entry)); if (text2 && (strlen (text2) < minlen)) goto done; } entry = glade_xml_get_widget (xml, "code3_entry"); if (g_object_get_data (G_OBJECT (entry), "active")) { minlen = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (entry), "minlen")); text3 = gtk_entry_get_text (GTK_ENTRY (entry)); if (text3 && (strlen (text3) < minlen)) goto done; } /* Validate 2 & 3 if they are supposed to be the same */ match23 = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (dialog), "match23")); if (match23) { if (!text2 || !text3 || strcmp (text2, text3)) goto done; } valid = TRUE; done: /* Clear any error text in the progress label now that the user has changed something */ widget = glade_xml_get_widget (xml, "progress_label"); gtk_label_set_text (GTK_LABEL (widget), ""); widget = glade_xml_get_widget (xml, "unlock_button"); g_warn_if_fail (widget != NULL); gtk_widget_set_sensitive (widget, valid); if (valid) gtk_widget_grab_default (widget); }
void gdb_mi_value_free(struct gdb_mi_value *val) { if (! val) return; switch (val->type) { case GDB_MI_VAL_STRING: g_free(val->string); g_warn_if_fail(val->list == NULL); break; case GDB_MI_VAL_LIST: gdb_mi_result_free(val->list, TRUE); g_warn_if_fail(val->string == NULL); break; } g_free(val); }
/** * soup_uri_host_equal: * @v1: (type Soup.URI): a #SoupURI with a non-%NULL @host member * @v2: (type Soup.URI): a #SoupURI with a non-%NULL @host member * * Compares @v1 and @v2, considering only the scheme, host, and port. * * Return value: whether or not the URIs are equal in scheme, host, * and port. * * Since: 2.28 **/ gboolean soup_uri_host_equal (gconstpointer v1, gconstpointer v2) { const SoupURI *one = v1; const SoupURI *two = v2; g_return_val_if_fail (one != NULL && two != NULL, one == two); g_return_val_if_fail (one->host != NULL && two->host != NULL, one->host == two->host); g_warn_if_fail (SOUP_URI_IS_VALID (one)); g_warn_if_fail (SOUP_URI_IS_VALID (two)); if (one->scheme != two->scheme) return FALSE; if (one->port != two->port) return FALSE; return g_ascii_strcasecmp (one->host, two->host) == 0; }
static GObject * g_local_directory_monitor_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) { GObject *obj; GLocalDirectoryMonitorClass *klass; GObjectClass *parent_class; GLocalDirectoryMonitor *local_monitor; const gchar *dirname = NULL; gint i; klass = G_LOCAL_DIRECTORY_MONITOR_CLASS (g_type_class_peek (G_TYPE_LOCAL_DIRECTORY_MONITOR)); parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (klass)); obj = parent_class->constructor (type, n_construct_properties, construct_properties); local_monitor = G_LOCAL_DIRECTORY_MONITOR (obj); for (i = 0; i < n_construct_properties; i++) { if (strcmp ("dirname", g_param_spec_get_name (construct_properties[i].pspec)) == 0) { g_warn_if_fail (G_VALUE_HOLDS_STRING (construct_properties[i].value)); dirname = g_value_get_string (construct_properties[i].value); break; } } local_monitor->dirname = g_strdup (dirname); if (!klass->mount_notify) { #ifdef G_OS_WIN32 /*claim everything was mounted */ local_monitor->was_mounted = TRUE; #else GUnixMountEntry *mount; /* Emulate unmount detection */ mount = g_unix_mount_at (local_monitor->dirname, NULL); local_monitor->was_mounted = mount != NULL; if (mount) g_unix_mount_free (mount); local_monitor->mount_monitor = g_unix_mount_monitor_new (); g_signal_connect_object (local_monitor->mount_monitor, "mounts-changed", G_CALLBACK (mounts_changed), local_monitor, 0); #endif } return obj; }