/** * soup_uri_new_with_base: * @base: a base URI * @uri_string: the URI * * Parses @uri_string relative to @base. * * Return value: a parsed #SoupURI. **/ SoupURI * soup_uri_new_with_base (SoupURI *base, const char *uri_string) { SoupURI *uri; const char *end, *hash, *colon, *at, *path, *question; const char *p, *hostend; gboolean remove_dot_segments = TRUE; uri = g_slice_new0 (SoupURI); /* See RFC 3986 for details. IF YOU CHANGE ANYTHING IN THIS * FUNCTION, RUN tests/uri-parsing AFTERWARDS. */ /* Find fragment. */ end = hash = strchr (uri_string, '#'); if (hash && hash[1]) { uri->fragment = uri_normalized_copy (hash + 1, strlen (hash + 1), NULL, FALSE); if (!uri->fragment) { soup_uri_free (uri); return NULL; } } else end = uri_string + strlen (uri_string); /* Find scheme: initial [a-z+.-]* substring until ":" */ p = uri_string; while (p < end && (g_ascii_isalnum (*p) || *p == '.' || *p == '+' || *p == '-')) p++; if (p > uri_string && *p == ':') { uri->scheme = soup_uri_get_scheme (uri_string, p - uri_string); if (!uri->scheme) { soup_uri_free (uri); return NULL; } uri_string = p + 1; } if (!*uri_string && !base) return uri; /* Check for authority */ if (strncmp (uri_string, "//", 2) == 0) { uri_string += 2; path = uri_string + strcspn (uri_string, "/?#"); at = strchr (uri_string, '@'); if (at && at < path) { colon = strchr (uri_string, ':'); if (colon && colon < at) { uri->password = uri_decoded_copy (colon + 1, at - colon - 1); if (!uri->password) { soup_uri_free (uri); return NULL; } } else { uri->password = NULL; colon = at; } uri->user = uri_decoded_copy (uri_string, colon - uri_string); if (!uri->user) { soup_uri_free (uri); return NULL; } uri_string = at + 1; } else uri->user = uri->password = NULL; /* Find host and port. */ if (*uri_string == '[') { uri_string++; hostend = strchr (uri_string, ']'); if (!hostend || hostend > path) { soup_uri_free (uri); return NULL; } if (*(hostend + 1) == ':') colon = hostend + 1; else colon = NULL; } else { colon = memchr (uri_string, ':', path - uri_string); hostend = colon ? colon : path; } uri->host = uri_decoded_copy (uri_string, hostend - uri_string); if (!uri->host) { soup_uri_free (uri); return NULL; } if (colon && colon != path - 1) { char *portend; uri->port = strtoul (colon + 1, &portend, 10); if (portend != (char *)path) { soup_uri_free (uri); return NULL; } } uri_string = path; } /* Find query */ question = memchr (uri_string, '?', end - uri_string); if (question) { if (question[1]) { uri->query = uri_normalized_copy (question + 1, end - (question + 1), NULL, TRUE); if (!uri->query) { soup_uri_free (uri); return NULL; } } end = question; } if (end != uri_string) { uri->path = uri_normalized_copy (uri_string, end - uri_string, NULL, TRUE); if (!uri->path) { soup_uri_free (uri); return NULL; } } /* Apply base URI. Again, this is spelled out in RFC 3986. */ if (base && !uri->scheme && uri->host) uri->scheme = base->scheme; else if (base && !uri->scheme) { uri->scheme = base->scheme; uri->user = g_strdup (base->user); uri->password = g_strdup (base->password); uri->host = g_strdup (base->host); uri->port = base->port; if (!uri->path) { uri->path = g_strdup (base->path); if (!uri->query) uri->query = g_strdup (base->query); remove_dot_segments = FALSE; } else if (*uri->path != '/') { char *newpath, *last; last = strrchr (base->path, '/'); if (last) { newpath = g_strdup_printf ("%.*s/%s", (int)(last - base->path), base->path, uri->path); } else newpath = g_strdup_printf ("/%s", uri->path); g_free (uri->path); uri->path = newpath; } } if (remove_dot_segments && uri->path && *uri->path) { char *p = uri->path, *q; /* Remove "./" where "." is a complete segment. */ for (p = uri->path + 1; *p; ) { if (*(p - 1) == '/' && *p == '.' && *(p + 1) == '/') memmove (p, p + 2, strlen (p + 2) + 1); else p++; } /* Remove "." at end. */ if (p > uri->path + 2 && *(p - 1) == '.' && *(p - 2) == '/') *(p - 1) = '\0'; /* Remove "<segment>/../" where <segment> != ".." */ for (p = uri->path + 1; *p; ) { if (!strncmp (p, "../", 3)) { p += 3; continue; } q = strchr (p + 1, '/'); if (!q) break; if (strncmp (q, "/../", 4) != 0) { p = q + 1; continue; } memmove (p, q + 4, strlen (q + 4) + 1); p = uri->path + 1; } /* Remove "<segment>/.." at end where <segment> != ".." */ q = strrchr (uri->path, '/'); if (q && !strcmp (q, "/..")) { p = q - 1; while (p > uri->path && *p != '/') p--; if (strncmp (p, "/../", 4) != 0) *(p + 1) = 0; } /* Remove extraneous initial "/.."s */ while (!strncmp (uri->path, "/../", 4)) memmove (uri->path, uri->path + 3, strlen (uri->path) - 2); if (!strcmp (uri->path, "/..")) uri->path[1] = '\0'; } /* HTTP-specific stuff */ if (uri->scheme == SOUP_URI_SCHEME_HTTP || uri->scheme == SOUP_URI_SCHEME_HTTPS) { if (!SOUP_URI_VALID_FOR_HTTP (uri)) { soup_uri_free (uri); return NULL; } if (!uri->path) uri->path = g_strdup ("/"); } if (!uri->port) uri->port = soup_scheme_default_port (uri->scheme); if (!uri->path) uri->path = g_strdup (""); return uri; }
g_base_info_get_name((GIBaseInfo*) info)); return NULL; } GJS_NATIVE_CONSTRUCTOR_DECLARE(union) { GJS_NATIVE_CONSTRUCTOR_VARIABLES(union) Union *priv; Union *proto_priv; JSObject *proto; void *gboxed; GJS_NATIVE_CONSTRUCTOR_PRELUDE(union); priv = g_slice_new0(Union); GJS_INC_COUNTER(boxed); g_assert(priv_from_js(context, object) == NULL); JS_SetPrivate(object, priv); gjs_debug_lifecycle(GJS_DEBUG_GBOXED, "union constructor, obj %p priv %p", object, priv); proto = JS_GetPrototype(object); gjs_debug_lifecycle(GJS_DEBUG_GBOXED, "union instance __proto__ is %p", proto); /* If we're the prototype, then post-construct we'll fill in priv->info. * If we are not the prototype, though, then we'll get ->info from the
static ModuleInfo * load_module (RuleInfo *info, gboolean initialize) { ModuleInfo *module_info = NULL; if (modules) { module_info = g_hash_table_lookup (modules, info->module_path); } if (!module_info) { GModule *module; /* Load the module */ module = g_module_open (info->module_path, G_MODULE_BIND_LOCAL); if (!module) { g_warning ("Could not load module '%s': %s", info->module_path, g_module_error ()); return NULL; } g_module_make_resident (module); module_info = g_slice_new0 (ModuleInfo); module_info->module = module; if (!g_module_symbol (module, EXTRACTOR_FUNCTION, (gpointer *) &module_info->extract_func)) { g_warning ("Could not load module '%s': Function %s() was not found, is it exported?", g_module_name (module), EXTRACTOR_FUNCTION); g_slice_free (ModuleInfo, module_info); return NULL; } g_module_symbol (module, INIT_FUNCTION, (gpointer *) &module_info->init_func); g_module_symbol (module, SHUTDOWN_FUNCTION, (gpointer *) &module_info->shutdown_func); /* Add it to the cache */ if (G_UNLIKELY (!modules)) { /* Key is an intern string, so * pointer comparison suffices */ modules = g_hash_table_new (NULL, NULL); } g_hash_table_insert (modules, (gpointer) info->module_path, module_info); } if (module_info && initialize && !module_info->initialized) { if (module_info->init_func) { GError *error = NULL; if (!(module_info->init_func) (&module_info->thread_awareness, &error)) { g_critical ("Could not initialize module %s: %s", g_module_name (module_info->module), (error) ? error->message : "No error given"); if (error) { g_error_free (error); } return NULL; } } else { module_info->thread_awareness = TRACKER_MODULE_MAIN_THREAD; } module_info->initialized = TRUE; } return module_info; }
static gboolean component_source_prepare (GSource *source, gint *timeout_) { ComponentSource *component_source = (ComponentSource *) source; NiceAgent *agent; NiceComponent *component; GSList *parentl, *childl; agent = g_weak_ref_get (&component_source->agent_ref); if (!agent) return FALSE; /* Needed due to accessing the Component. */ agent_lock (); if (!agent_find_component (agent, component_source->stream_id, component_source->component_id, NULL, &component)) goto done; if (component->socket_sources_age == component_source->component_socket_sources_age) goto done; /* If the age has changed, either * - one or more new socket has been prepended * - old sockets have been removed */ /* Add the new child sources. */ for (parentl = component->socket_sources; parentl; parentl = parentl->next) { SocketSource *parent_socket_source = parentl->data; SocketSource *child_socket_source; if (parent_socket_source->socket->fileno == NULL) continue; /* Iterating the list of socket sources every time isn't a big problem * because the number of pairs is limited ~100 normally, so there will * rarely be more than 10. */ childl = g_slist_find_custom (component_source->socket_sources, parent_socket_source->socket, _find_socket_source); /* If we have reached this state, then all sources new sources have been * added, because they are always prepended. */ if (childl) break; child_socket_source = g_slice_new0 (SocketSource); child_socket_source->socket = parent_socket_source->socket; child_socket_source->source = g_socket_create_source (child_socket_source->socket->fileno, G_IO_IN, NULL); g_source_set_dummy_callback (child_socket_source->source); g_source_add_child_source (source, child_socket_source->source); g_source_unref (child_socket_source->source); component_source->socket_sources = g_slist_prepend (component_source->socket_sources, child_socket_source); } for (childl = component_source->socket_sources; childl;) { SocketSource *child_socket_source = childl->data; GSList *next = childl->next; parentl = g_slist_find_custom (component->socket_sources, child_socket_source->socket, _find_socket_source); /* If this is not a currently used socket, remove the relevant source */ if (!parentl) { g_source_remove_child_source (source, child_socket_source->source); g_slice_free (SocketSource, child_socket_source); component_source->socket_sources = g_slist_delete_link (component_source->socket_sources, childl); } childl = next; } /* Update the age. */ component_source->component_socket_sources_age = component->socket_sources_age; done: agent_unlock_and_emit (agent); g_object_unref (agent); /* We can’t be sure if the ComponentSource itself needs to be dispatched until * poll() is called on all the child sources. */ return FALSE; }
/** * ephy_web_application_get_application_list: * * Gets a list of the currently installed web applications. * Free the returned GList with * ephy_web_application_free_application_list. * * Returns: (transfer-full): a #GList of #EphyWebApplication objects **/ GList * ephy_web_application_get_application_list () { GFileEnumerator *children = NULL; GFileInfo *info; GList *applications = NULL; GFile *dot_dir; dot_dir = g_file_new_for_path (ephy_dot_dir ()); children = g_file_enumerate_children (dot_dir, "standard::name", 0, NULL, NULL); g_object_unref (dot_dir); info = g_file_enumerator_next_file (children, NULL, NULL); while (info) { EphyWebApplication *app; const char *name; glong prefix_length = g_utf8_strlen (EPHY_WEB_APP_PREFIX, -1); name = g_file_info_get_name (info); if (g_str_has_prefix (name, EPHY_WEB_APP_PREFIX)) { char *profile_dir; guint64 created; GDate *date; char *desktop_file, *desktop_file_path; char *contents; GFileInfo *desktop_info; app = g_slice_new0 (EphyWebApplication); profile_dir = g_build_filename (ephy_dot_dir (), name, NULL); app->icon_url = g_build_filename (profile_dir, EPHY_WEB_APP_ICON_NAME, NULL); desktop_file = g_strconcat (name + prefix_length, ".desktop", NULL); desktop_file_path = g_build_filename (profile_dir, desktop_file, NULL); app->desktop_file = g_strdup (desktop_file); if (g_file_get_contents (desktop_file_path, &contents, NULL, NULL)) { char *exec; char **strings; GKeyFile *key; int i; GFile *file; key = g_key_file_new (); g_key_file_load_from_data (key, contents, -1, 0, NULL); app->name = g_key_file_get_string (key, "Desktop Entry", "Name", NULL); exec = g_key_file_get_string (key, "Desktop Entry", "Exec", NULL); strings = g_strsplit (exec, " ", -1); for (i = 0; strings[i]; i++); app->url = g_strdup (strings[i - 1]); g_strfreev (strings); g_free (exec); g_key_file_free (key); file = g_file_new_for_path (desktop_file_path); /* FIXME: this should use TIME_CREATED but it does not seem to be working. */ desktop_info = g_file_query_info (file, G_FILE_ATTRIBUTE_TIME_MODIFIED, 0, NULL, NULL); created = g_file_info_get_attribute_uint64 (desktop_info, G_FILE_ATTRIBUTE_TIME_MODIFIED); date = g_date_new (); g_date_set_time_t (date, (time_t)created); g_date_strftime (app->install_date, 127, "%x", date); g_date_free (date); g_object_unref (file); g_object_unref (desktop_info); applications = g_list_append (applications, app); } g_free (contents); g_free (desktop_file); g_free (profile_dir); g_free (desktop_file_path); } g_object_unref (info); info = g_file_enumerator_next_file (children, NULL, NULL); } g_object_unref (children); return applications; }
static gpointer _parse_atsc_eit (GstMpegtsSection * section) { GstMpegtsAtscEIT *eit = NULL; guint i = 0; guint8 *data, *end; guint8 num_events; eit = g_slice_new0 (GstMpegtsAtscEIT); data = section->data; end = data + section->section_length; eit->source_id = section->subtable_extension; /* Skip already parsed data */ data += 8; eit->protocol_version = GST_READ_UINT8 (data); data += 1; num_events = GST_READ_UINT8 (data); data += 1; eit->events = g_ptr_array_new_with_free_func ((GDestroyNotify) _gst_mpegts_atsc_eit_event_free); for (i = 0; i < num_events; i++) { GstMpegtsAtscEITEvent *event; guint32 tmp; guint8 text_length; guint16 descriptors_loop_length; if (end - data < 12) { GST_WARNING ("PID %d invalid EIT entry length %d with %u events", section->pid, (gint) (end - 4 - data), num_events); goto error; } event = g_slice_new0 (GstMpegtsAtscEITEvent); g_ptr_array_add (eit->events, event); event->event_id = GST_READ_UINT16_BE (data) & 0x3FFF; data += 2; event->start_time = GST_READ_UINT32_BE (data); data += 4; tmp = GST_READ_UINT32_BE (data); data += 4; event->etm_location = (tmp >> 28) & 0x3; event->length_in_seconds = (tmp >> 8) & 0x0FFFFF; text_length = tmp & 0xFF; if (text_length > end - data - 4 - 2) { GST_WARNING ("PID %d invalid EIT entry length %d with %u events", section->pid, (gint) (end - 4 - data), num_events); goto error; } event->titles = _parse_atsc_mult_string (data, text_length); data += text_length; descriptors_loop_length = GST_READ_UINT16_BE (data) & 0x0FFF; data += 2; if (end - data - 4 < descriptors_loop_length) { GST_WARNING ("PID %d invalid EIT entry length %d with %u events", section->pid, (gint) (end - 4 - data), num_events); goto error; } event->descriptors = gst_mpegts_parse_descriptors (data, descriptors_loop_length); data += descriptors_loop_length; } if (data != end - 4) { GST_WARNING ("PID %d invalid EIT parsed %d length %d", section->pid, (gint) (data - section->data), section->section_length); goto error; } return (gpointer) eit; error: _gst_mpegts_atsc_eit_free (eit); return NULL; }
/** * gst_video_convert_sample_async: * @sample: a #GstSample * @to_caps: the #GstCaps to convert to * @timeout: the maximum amount of time allowed for the processing. * @callback: %GstVideoConvertSampleCallback that will be called after conversion. * @user_data: extra data that will be passed to the @callback * @destroy_notify: %GDestroyNotify to be called after @user_data is not needed anymore * * Converts a raw video buffer into the specified output caps. * * The output caps can be any raw video formats or any image formats (jpeg, png, ...). * * The width, height and pixel-aspect-ratio can also be specified in the output caps. * * @callback will be called after conversion, when an error occured or if conversion didn't * finish after @timeout. @callback will always be called from the thread default * %GMainContext, see g_main_context_get_thread_default(). If GLib before 2.22 is used, * this will always be the global default main context. * * @destroy_notify will be called after the callback was called and @user_data is not needed * anymore. */ void gst_video_convert_sample_async (GstSample * sample, const GstCaps * to_caps, GstClockTime timeout, GstVideoConvertSampleCallback callback, gpointer user_data, GDestroyNotify destroy_notify) { GMainContext *context = NULL; GError *error = NULL; GstBus *bus; GstBuffer *buf; GstCaps *from_caps, *to_caps_copy = NULL; GstElement *pipeline, *src, *sink; guint i, n; GSource *source; GstVideoConvertSampleContext *ctx; g_return_if_fail (sample != NULL); buf = gst_sample_get_buffer (sample); g_return_if_fail (buf != NULL); g_return_if_fail (to_caps != NULL); from_caps = gst_sample_get_caps (sample); g_return_if_fail (from_caps != NULL); g_return_if_fail (callback != NULL); context = g_main_context_get_thread_default (); if (!context) context = g_main_context_default (); to_caps_copy = gst_caps_new_empty (); n = gst_caps_get_size (to_caps); for (i = 0; i < n; i++) { GstStructure *s = gst_caps_get_structure (to_caps, i); s = gst_structure_copy (s); gst_structure_remove_field (s, "framerate"); gst_caps_append_structure (to_caps_copy, s); } pipeline = build_convert_frame_pipeline (&src, &sink, from_caps, gst_buffer_get_video_crop_meta (buf), to_caps_copy, &error); if (!pipeline) goto no_pipeline; bus = gst_element_get_bus (pipeline); ctx = g_slice_new0 (GstVideoConvertSampleContext); g_mutex_init (&ctx->mutex); //ctx->buffer = gst_buffer_ref (buf); ctx->sample = gst_sample_ref (sample); ctx->callback = callback; ctx->user_data = user_data; ctx->destroy_notify = destroy_notify; ctx->context = g_main_context_ref (context); ctx->finished = FALSE; ctx->pipeline = pipeline; if (timeout != GST_CLOCK_TIME_NONE) { ctx->timeout_source = g_timeout_source_new (timeout / GST_MSECOND); g_source_set_callback (ctx->timeout_source, (GSourceFunc) convert_frame_timeout_callback, ctx, NULL); g_source_attach (ctx->timeout_source, context); } g_signal_connect (src, "need-data", G_CALLBACK (convert_frame_need_data_callback), ctx); g_signal_connect (sink, "new-preroll", G_CALLBACK (convert_frame_new_preroll_callback), ctx); source = gst_bus_create_watch (bus); g_source_set_callback (source, (GSourceFunc) convert_frame_bus_callback, ctx, NULL); g_source_attach (source, context); g_source_unref (source); gst_element_set_state (pipeline, GST_STATE_PLAYING); gst_object_unref (bus); gst_caps_unref (to_caps_copy); return; /* ERRORS */ no_pipeline: { GstVideoConvertSampleCallbackContext *ctx; GSource *source; gst_caps_unref (to_caps_copy); ctx = g_slice_new0 (GstVideoConvertSampleCallbackContext); ctx->callback = callback; ctx->user_data = user_data; ctx->destroy_notify = destroy_notify; ctx->sample = NULL; ctx->error = error; source = g_timeout_source_new (0); g_source_set_callback (source, (GSourceFunc) convert_frame_dispatch_callback, ctx, (GDestroyNotify) gst_video_convert_frame_callback_context_free); g_source_attach (source, context); g_source_unref (source); } }
static GstFlowReturn gst_rtp_pt_demux_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) { GstFlowReturn ret = GST_FLOW_OK; GstRtpPtDemux *rtpdemux; guint8 pt; GstPad *srcpad; GstCaps *caps; GstRTPBuffer rtp = { NULL }; rtpdemux = GST_RTP_PT_DEMUX (parent); if (!gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp)) goto invalid_buffer; pt = gst_rtp_buffer_get_payload_type (&rtp); gst_rtp_buffer_unmap (&rtp); GST_DEBUG_OBJECT (rtpdemux, "received buffer for pt %d", pt); srcpad = find_pad_for_pt (rtpdemux, pt); if (srcpad == NULL) { /* new PT, create a src pad */ GstRtpPtDemuxPad *rtpdemuxpad; GstElementClass *klass; GstPadTemplate *templ; gchar *padname; caps = gst_rtp_pt_demux_get_caps (rtpdemux, pt); if (!caps) goto no_caps; klass = GST_ELEMENT_GET_CLASS (rtpdemux); templ = gst_element_class_get_pad_template (klass, "src_%u"); padname = g_strdup_printf ("src_%u", pt); srcpad = gst_pad_new_from_template (templ, padname); gst_pad_use_fixed_caps (srcpad); g_free (padname); gst_pad_set_event_function (srcpad, gst_rtp_pt_demux_src_event); GST_DEBUG ("Adding pt=%d to the list.", pt); rtpdemuxpad = g_slice_new0 (GstRtpPtDemuxPad); rtpdemuxpad->pt = pt; rtpdemuxpad->newcaps = FALSE; rtpdemuxpad->pad = srcpad; gst_object_ref (srcpad); GST_OBJECT_LOCK (rtpdemux); rtpdemux->srcpads = g_slist_append (rtpdemux->srcpads, rtpdemuxpad); GST_OBJECT_UNLOCK (rtpdemux); gst_pad_set_active (srcpad, TRUE); /* First push the stream-start event, it must always come first */ gst_pad_push_event (srcpad, gst_pad_get_sticky_event (rtpdemux->sink, GST_EVENT_STREAM_START, 0)); /* Then caps event is sent */ caps = gst_caps_make_writable (caps); gst_caps_set_simple (caps, "payload", G_TYPE_INT, pt, NULL); gst_pad_set_caps (srcpad, caps); gst_caps_unref (caps); /* First sticky events on sink pad are forwarded to the new src pad */ gst_pad_sticky_events_foreach (rtpdemux->sink, forward_sticky_events, srcpad); gst_element_add_pad (GST_ELEMENT_CAST (rtpdemux), srcpad); GST_DEBUG ("emitting new-payload-type for pt %d", pt); g_signal_emit (G_OBJECT (rtpdemux), gst_rtp_pt_demux_signals[SIGNAL_NEW_PAYLOAD_TYPE], 0, pt, srcpad); } if (pt != rtpdemux->last_pt) { gint emit_pt = pt; /* our own signal with an extra flag that this is the only pad */ rtpdemux->last_pt = pt; GST_DEBUG ("emitting payload-type-changed for pt %d", emit_pt); g_signal_emit (G_OBJECT (rtpdemux), gst_rtp_pt_demux_signals[SIGNAL_PAYLOAD_TYPE_CHANGE], 0, emit_pt); } while (need_caps_for_pt (rtpdemux, pt)) { GST_DEBUG ("need new caps for %d", pt); caps = gst_rtp_pt_demux_get_caps (rtpdemux, pt); if (!caps) goto no_caps; clear_newcaps_for_pt (rtpdemux, pt); caps = gst_caps_make_writable (caps); gst_caps_set_simple (caps, "payload", G_TYPE_INT, pt, NULL); gst_pad_set_caps (srcpad, caps); gst_caps_unref (caps); } /* push to srcpad */ ret = gst_pad_push (srcpad, buf); gst_object_unref (srcpad); return ret; /* ERRORS */ invalid_buffer: { /* this is fatal and should be filtered earlier */ GST_ELEMENT_ERROR (rtpdemux, STREAM, DECODE, (NULL), ("Dropping invalid RTP payload")); gst_buffer_unref (buf); return GST_FLOW_ERROR; } no_caps: { GST_ELEMENT_ERROR (rtpdemux, STREAM, DECODE, (NULL), ("Could not get caps for payload")); gst_buffer_unref (buf); if (srcpad) gst_object_unref (srcpad); return GST_FLOW_ERROR; } }
/** * empathy_irc_network_dialog_show: * @network: the #EmpathyIrcNetwork to configure * @parent: the parent of this dialog * * Display a dialog to configure a given #EmpathyIrcNetwork. * This function is a singleton so if a configuration dialog already * exists we use this one to edit the network. * * Returns: The displayed #GtkDialog */ GtkWidget * empathy_irc_network_dialog_show (EmpathyIrcNetwork *network, GtkWidget *parent) { static EmpathyIrcNetworkDialog *dialog = NULL; GladeXML *glade; GtkListStore *store; GtkCellRenderer *renderer; GtkAdjustment *adjustment; GtkTreeSelection *selection; GtkTreeViewColumn *column; gchar *filename; g_return_val_if_fail (network != NULL, NULL); if (dialog != NULL) { change_network (dialog, network); gtk_window_present (GTK_WINDOW (dialog->dialog)); return dialog->dialog; } dialog = g_slice_new0 (EmpathyIrcNetworkDialog); dialog->network = network; g_object_ref (dialog->network); filename = empathy_file_lookup ("empathy-account-widget-irc.glade", "libempathy-gtk"); glade = empathy_glade_get_file (filename, "irc_network_dialog", NULL, "irc_network_dialog", &dialog->dialog, "button_close", &dialog->button_close, "entry_network", &dialog->entry_network, "combobox_charset", &dialog->combobox_charset, "treeview_servers", &dialog->treeview_servers, "button_add", &dialog->button_add, "button_remove", &dialog->button_remove, "button_up", &dialog->button_up, "button_down", &dialog->button_down, NULL); g_free (filename); store = gtk_list_store_new (4, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_BOOLEAN); gtk_tree_view_set_model (GTK_TREE_VIEW (dialog->treeview_servers), GTK_TREE_MODEL (store)); g_object_unref (store); /* address */ renderer = gtk_cell_renderer_text_new (); g_object_set (renderer, "editable", TRUE, NULL); g_signal_connect (renderer, "edited", G_CALLBACK (irc_network_dialog_address_edited_cb), dialog); gtk_tree_view_insert_column_with_attributes ( GTK_TREE_VIEW (dialog->treeview_servers), -1, _("Server"), renderer, "text", COL_ADR, NULL); /* port */ adjustment = (GtkAdjustment *) gtk_adjustment_new (6667, 1, G_MAXUINT16, 1, 10, 0); renderer = gtk_cell_renderer_spin_new (); g_object_set (renderer, "editable", TRUE, "adjustment", adjustment, NULL); g_signal_connect (renderer, "edited", G_CALLBACK (irc_network_dialog_port_edited_cb), dialog); gtk_tree_view_insert_column_with_attributes ( GTK_TREE_VIEW (dialog->treeview_servers), -1, _("Port"), renderer, "text", COL_PORT, NULL); column = gtk_tree_view_get_column (GTK_TREE_VIEW (dialog->treeview_servers), 1); gtk_tree_view_column_set_expand (column, TRUE); /* SSL */ renderer = gtk_cell_renderer_toggle_new (); g_object_set (renderer, "activatable", TRUE, NULL); g_signal_connect (renderer, "toggled", G_CALLBACK (irc_network_dialog_ssl_toggled_cb), dialog); gtk_tree_view_insert_column_with_attributes ( GTK_TREE_VIEW (dialog->treeview_servers), -1, _("SSL"), renderer, "active", COL_SSL, NULL); selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW (dialog->treeview_servers)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); /* charset */ totem_subtitle_encoding_init (GTK_COMBO_BOX (dialog->combobox_charset)); irc_network_dialog_setup (dialog); empathy_glade_connect (glade, dialog, "irc_network_dialog", "destroy", irc_network_dialog_destroy_cb, "button_close", "clicked", irc_network_dialog_close_clicked_cb, "entry_network", "focus-out-event", irc_network_dialog_network_focus_cb, "button_add", "clicked", irc_network_dialog_button_add_clicked_cb, "button_remove", "clicked", irc_network_dialog_button_remove_clicked_cb, "button_up", "clicked", irc_network_dialog_button_up_clicked_cb, "button_down", "clicked", irc_network_dialog_button_down_clicked_cb, "combobox_charset", "changed", irc_network_dialog_combobox_charset_changed_cb, NULL); g_object_unref (glade); g_object_add_weak_pointer (G_OBJECT (dialog->dialog), (gpointer) &dialog); g_signal_connect (selection, "changed", G_CALLBACK (irc_network_dialog_selection_changed_cb), dialog); gtk_window_set_transient_for (GTK_WINDOW (dialog->dialog), GTK_WINDOW (parent)); gtk_window_set_modal (GTK_WINDOW (dialog->dialog), TRUE); irc_network_dialog_network_update_buttons (dialog); return dialog->dialog; }
static gboolean process (GeglOperation *operation, GeglBuffer *input, GeglBuffer *output, const GeglRectangle *roi, gint level) { GeglProperties *o = GEGL_PROPERTIES (operation); gdouble percentile = o->percentile / 100.0; gdouble alpha_percentile = o->alpha_percentile / 100.0; const gint *neighborhood_outline = o->user_data; const Babl *format = gegl_operation_get_format (operation, "input"); gint n_components = babl_format_get_n_components (format); gboolean has_alpha = babl_format_has_alpha (format); G_STATIC_ASSERT (sizeof (gint32) == sizeof (gfloat)); gint32 *src_buf; gfloat *dst_buf; GeglRectangle src_rect; gint src_stride; gint dst_stride; gint n_pixels; Histogram *hist; const gint32 *src; gfloat *dst; gint dst_x, dst_y; Direction dir; gint i; gint c; src_rect = gegl_operation_get_required_for_output (operation, "input", roi); src_stride = src_rect.width * n_components; dst_stride = roi->width * n_components; n_pixels = roi->width * roi->height; dst_buf = g_new0 (gfloat, n_pixels * n_components); src_buf = g_new0 (gint32, src_rect.width * src_rect.height * n_components); gegl_buffer_get (input, &src_rect, 1.0, format, src_buf, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_CLAMP); convert_values_to_bins (src_buf, n_components, has_alpha, src_rect.width * src_rect.height); hist = g_slice_new0 (Histogram); src = src_buf + o->radius * (src_rect.width + 1) * n_components; dst = dst_buf; /* compute the first window */ for (i = -o->radius; i <= o->radius; i++) { histogram_modify_vals (hist, src, n_components, src_stride, has_alpha, i, -neighborhood_outline[abs (i)], i, +neighborhood_outline[abs (i)], +1); hist->size += 2 * neighborhood_outline[abs (i)] + 1; } for (c = 0; c < 3; c++) dst[c] = histogram_get_median (hist, c, percentile); if (has_alpha) dst[3] = histogram_get_median (hist, 3, alpha_percentile); dst_x = 0; dst_y = 0; n_pixels--; dir = LEFT_TO_RIGHT; while (n_pixels--) { /* move the src coords based on current direction and positions */ if (dir == LEFT_TO_RIGHT) { if (dst_x != roi->width - 1) { dst_x++; src += n_components; dst += n_components; } else { dst_y++; src += src_stride; dst += dst_stride; dir = TOP_TO_BOTTOM; } } else if (dir == TOP_TO_BOTTOM) { if (dst_x == 0) { dst_x++; src += n_components; dst += n_components; dir = LEFT_TO_RIGHT; } else { dst_x--; src -= n_components; dst -= n_components; dir = RIGHT_TO_LEFT; } } else if (dir == RIGHT_TO_LEFT) { if (dst_x != 0) { dst_x--; src -= n_components; dst -= n_components; } else { dst_y++; src += src_stride; dst += dst_stride; dir = TOP_TO_BOTTOM; } } histogram_update (hist, src, n_components, src_stride, has_alpha, o->neighborhood, o->radius, neighborhood_outline, dir); for (c = 0; c < 3; c++) dst[c] = histogram_get_median (hist, c, percentile); if (has_alpha) dst[3] = histogram_get_median (hist, 3, alpha_percentile); } gegl_buffer_set (output, roi, 0, format, dst_buf, GEGL_AUTO_ROWSTRIDE); g_slice_free (Histogram, hist); g_free (dst_buf); g_free (src_buf); return TRUE; }
GtkWidget* file_properties_dlg_new( GtkWindow* parent, const char* dir_path, GList* sel_files, int page ) { GtkBuilder* builder = _gtk_builder_new_from_file( PACKAGE_UI_DIR "/file_properties.ui", NULL ); GtkWidget * dlg = (GtkWidget*)gtk_builder_get_object( builder, "dlg" ); GtkNotebook* notebook = (GtkNotebook*)gtk_builder_get_object( builder, "notebook" ); xset_set_window_icon( GTK_WINDOW( dlg ) ); FilePropertiesDialogData* data; gboolean need_calc_size = TRUE; VFSFileInfo *file, *file2; VFSMimeType* mime; const char* multiple_files = _( "( multiple files )" ); const char* calculating; GtkWidget* name = (GtkWidget*)gtk_builder_get_object( builder, "file_name" ); GtkWidget* label_name = (GtkWidget*)gtk_builder_get_object( builder, "label_filename" ); GtkWidget* location = (GtkWidget*)gtk_builder_get_object( builder, "location" ); gtk_editable_set_editable ( GTK_EDITABLE( location ), FALSE ); GtkWidget* target = (GtkWidget*)gtk_builder_get_object( builder, "target" ); GtkWidget* label_target = (GtkWidget*)gtk_builder_get_object( builder, "label_target" ); gtk_editable_set_editable ( GTK_EDITABLE( target ), FALSE ); GtkWidget* mime_type = (GtkWidget*)gtk_builder_get_object( builder, "mime_type" ); GtkWidget* open_with = (GtkWidget*)gtk_builder_get_object( builder, "open_with" ); char buf[ 64 ]; char buf2[ 32 ]; const char* time_format = "%Y-%m-%d %H:%M:%S"; gchar* disp_path; gchar* file_type; int i; GList* l; gboolean same_type = TRUE; gboolean is_dirs = FALSE; char *owner_group, *tmp; gtk_dialog_set_alternative_button_order( GTK_DIALOG(dlg), GTK_RESPONSE_OK, GTK_RESPONSE_CANCEL, -1 ); ptk_dialog_fit_small_screen( GTK_DIALOG(dlg) ); int width = xset_get_int( "app_dlg", "s" ); int height = xset_get_int( "app_dlg", "z" ); if ( width && height ) gtk_window_set_default_size( GTK_WINDOW( dlg ), width, -1 ); data = g_slice_new0( FilePropertiesDialogData ); /* FIXME: When will the data be freed??? */ g_object_set_data( G_OBJECT( dlg ), "DialogData", data ); data->file_list = sel_files; data->dlg = dlg; data->dir_path = g_strdup( dir_path ); disp_path = g_filename_display_name( dir_path ); //gtk_label_set_text( GTK_LABEL( location ), disp_path ); gtk_entry_set_text( GTK_ENTRY( location ), disp_path ); g_free( disp_path ); data->total_size_label = GTK_LABEL( (GtkWidget*)gtk_builder_get_object( builder, "total_size" ) ); data->size_on_disk_label = GTK_LABEL( (GtkWidget*)gtk_builder_get_object( builder, "size_on_disk" ) ); data->count_label = GTK_LABEL( (GtkWidget*)gtk_builder_get_object( builder, "count" ) ); data->owner = GTK_ENTRY( (GtkWidget*)gtk_builder_get_object( builder, "owner" ) ); data->group = GTK_ENTRY( (GtkWidget*)gtk_builder_get_object( builder, "group" ) ); data->mtime = GTK_ENTRY( (GtkWidget*)gtk_builder_get_object( builder, "mtime" ) ); data->atime = GTK_ENTRY( (GtkWidget*)gtk_builder_get_object( builder, "atime" ) ); for ( i = 0; i < N_CHMOD_ACTIONS; ++i ) { data->chmod_btns[ i ] = GTK_TOGGLE_BUTTON( (GtkWidget*)gtk_builder_get_object( builder, chmod_names[ i ] ) ); } //MOD VFSMimeType* type; VFSMimeType* type2 = NULL; for ( l = sel_files; l ; l = l->next ) { file = ( VFSFileInfo* ) l->data; type = vfs_file_info_get_mime_type( file ); if ( !type2 ) type2 = vfs_file_info_get_mime_type( file ); if ( vfs_file_info_is_dir( file ) ) is_dirs = TRUE; if ( type != type2 ) same_type = FALSE; vfs_mime_type_unref( type ); if ( is_dirs && !same_type ) break; } if ( type2 ) vfs_mime_type_unref( type2 ); data->recurse = (GtkWidget*)gtk_builder_get_object( builder, "recursive" ); gtk_widget_set_sensitive( data->recurse, is_dirs ); /* //MOD for ( l = sel_files; l && l->next; l = l->next ) { VFSMimeType *type, *type2; file = ( VFSFileInfo* ) l->data; file2 = ( VFSFileInfo* ) l->next->data; type = vfs_file_info_get_mime_type( file ); type2 = vfs_file_info_get_mime_type( file2 ); if ( type != type2 ) { vfs_mime_type_unref( type ); vfs_mime_type_unref( type2 ); same_type = FALSE; break; } vfs_mime_type_unref( type ); vfs_mime_type_unref( type2 ); } */ file = ( VFSFileInfo* ) sel_files->data; if ( same_type ) { mime = vfs_file_info_get_mime_type( file ); file_type = g_strdup_printf( "%s\n%s", vfs_mime_type_get_description( mime ), vfs_mime_type_get_type( mime ) ); gtk_label_set_text( GTK_LABEL( mime_type ), file_type ); g_free( file_type ); vfs_mime_type_unref( mime ); } else { gtk_label_set_text( GTK_LABEL( mime_type ), _( "( multiple types )" ) ); } /* Open with... * Don't show this option menu if files of different types are selected, * ,the selected file is a folder, or its type is unknown. */ if( ! same_type || vfs_file_info_is_desktop_entry( file ) || /* vfs_file_info_is_unknown_type( file ) || */ vfs_file_info_is_executable( file, NULL ) ) { /* if open with shouldn't show, destroy it. */ gtk_widget_destroy( open_with ); open_with = NULL; gtk_widget_destroy( (GtkWidget*)gtk_builder_get_object( builder, "open_with_label" ) ); } else /* Add available actions to the option menu */ { GtkTreeIter it; char **action, **actions; mime = vfs_file_info_get_mime_type( file ); actions = vfs_mime_type_get_actions( mime ); GtkCellRenderer* renderer; GtkListStore* model; gtk_cell_layout_clear( GTK_CELL_LAYOUT(open_with) ); renderer = gtk_cell_renderer_pixbuf_new(); gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(open_with), renderer, FALSE); gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT(open_with), renderer, "pixbuf", 0, NULL ); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start( GTK_CELL_LAYOUT(open_with), renderer, TRUE); gtk_cell_layout_set_attributes( GTK_CELL_LAYOUT(open_with),renderer, "text", 1, NULL ); model = gtk_list_store_new( 3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING ); if( actions ) { for( action = actions; *action; ++action ) { VFSAppDesktop* desktop; GdkPixbuf* icon; desktop = vfs_app_desktop_new( *action ); gtk_list_store_append( model, &it ); icon = vfs_app_desktop_get_icon(desktop, 20, TRUE); gtk_list_store_set( model, &it, 0, icon, 1, vfs_app_desktop_get_disp_name(desktop), 2, *action, -1 ); if( icon ) g_object_unref( icon ); vfs_app_desktop_unref( desktop ); } } else { g_object_set_data( G_OBJECT(open_with), "prev_sel", GINT_TO_POINTER(-1) ); } /* separator */ gtk_list_store_append( model, &it ); gtk_list_store_append( model, &it ); gtk_list_store_set( model, &it, 0, NULL, 1, _("Choose..."), -1 ); gtk_combo_box_set_model( GTK_COMBO_BOX(open_with), GTK_TREE_MODEL(model) ); gtk_combo_box_set_row_separator_func( GTK_COMBO_BOX(open_with), combo_sep, NULL, NULL ); gtk_combo_box_set_active(GTK_COMBO_BOX(open_with), 0); g_signal_connect( open_with, "changed", G_CALLBACK(on_combo_change), mime ); /* vfs_mime_type_unref( mime ); */ /* We can unref mime when combo box gets destroyed */ g_object_weak_ref( G_OBJECT(open_with), (GWeakNotify)vfs_mime_type_unref, mime ); } g_object_set_data( G_OBJECT(dlg), "open_with", open_with ); /* Multiple files are selected */ if ( sel_files && sel_files->next ) { gtk_widget_set_sensitive( name, FALSE ); gtk_entry_set_text( GTK_ENTRY( name ), multiple_files ); data->orig_mtime = NULL; data->orig_atime = NULL; for ( i = 0; i < N_CHMOD_ACTIONS; ++i ) { gtk_toggle_button_set_inconsistent ( data->chmod_btns[ i ], TRUE ); data->chmod_states[ i ] = 2; /* Don't touch this bit */ g_signal_connect( G_OBJECT( data->chmod_btns[ i ] ), "toggled", G_CALLBACK( on_chmod_btn_toggled ), data ); } } else { /* special processing for files with special display names */ if( vfs_file_info_is_desktop_entry( file ) ) { char* disp_name = g_filename_display_name( file->name ); gtk_entry_set_text( GTK_ENTRY( name ), disp_name ); g_free( disp_name ); } else { if ( vfs_file_info_is_dir( file ) && !vfs_file_info_is_symlink( file ) ) gtk_label_set_markup_with_mnemonic( GTK_LABEL( label_name ), _("<b>Folder _Name:</b>") ); gtk_entry_set_text( GTK_ENTRY( name ), vfs_file_info_get_disp_name( file ) ); } gtk_editable_set_editable ( GTK_EDITABLE( name ), FALSE ); if ( ! vfs_file_info_is_dir( file ) ) { /* Only single "file" is selected, so we don't need to caculate total file size */ need_calc_size = FALSE; sprintf( buf, _("%s ( %lu bytes )"), vfs_file_info_get_disp_size( file ), ( guint64 ) vfs_file_info_get_size( file ) ); gtk_label_set_text( data->total_size_label, buf ); vfs_file_size_to_string( buf2, vfs_file_info_get_blocks( file ) * 512 ); sprintf( buf, _("%s ( %lu bytes )"), buf2, ( guint64 ) vfs_file_info_get_blocks( file ) * 512 ); gtk_label_set_text( data->size_on_disk_label, buf ); gtk_label_set_text( data->count_label, _("1 file") ); } // Modified / Accessed //gtk_entry_set_text( GTK_ENTRY( mtime ), // vfs_file_info_get_disp_mtime( file ) ); strftime( buf, sizeof( buf ), time_format, localtime( vfs_file_info_get_mtime( file ) ) ); gtk_entry_set_text( GTK_ENTRY( data->mtime ), buf ); data->orig_mtime = g_strdup( buf ); strftime( buf, sizeof( buf ), time_format, localtime( vfs_file_info_get_atime( file ) ) ); gtk_entry_set_text( GTK_ENTRY( data->atime ), buf ); data->orig_atime = g_strdup( buf ); // Permissions owner_group = (char *) vfs_file_info_get_disp_owner( file ); tmp = strchr( owner_group, ':' ); data->owner_name = g_strndup( owner_group, tmp - owner_group ); gtk_entry_set_text( GTK_ENTRY( data->owner ), data->owner_name ); data->group_name = g_strdup( tmp + 1 ); gtk_entry_set_text( GTK_ENTRY( data->group ), data->group_name ); for ( i = 0; i < N_CHMOD_ACTIONS; ++i ) { if ( data->chmod_states[ i ] != 2 ) /* allow to touch this bit */ { data->chmod_states[ i ] = ( vfs_file_info_get_mode( file ) & chmod_flags[ i ] ? 1 : 0 ); gtk_toggle_button_set_active( data->chmod_btns[ i ], data->chmod_states[ i ] ); } } // target if ( vfs_file_info_is_symlink( file ) ) { gtk_label_set_markup_with_mnemonic( GTK_LABEL( label_name ), _("<b>Link _Name:</b>") ); disp_path = g_build_filename( dir_path, file->name, NULL ); char* target_path = g_file_read_link( disp_path, NULL ); if ( target_path ) { gtk_entry_set_text( GTK_ENTRY( target ), target_path ); if ( target_path[0] && target_path[0] != '/' ) { // relative link to absolute char* str = target_path; target_path = g_build_filename( dir_path, str, NULL ); g_free( str ); } if ( !g_file_test( target_path, G_FILE_TEST_EXISTS ) ) gtk_label_set_text( GTK_LABEL( mime_type ), _("( broken link )") ); g_free( target_path ); } else gtk_entry_set_text( GTK_ENTRY( target ), _("( read link error )") ); g_free( disp_path ); gtk_widget_show( target ); gtk_widget_show( label_target ); } } if ( need_calc_size ) { /* The total file size displayed in "File Properties" is not completely calculated yet. So "Calculating..." is displayed. */ calculating = _( "Calculating..." ); gtk_label_set_text( data->total_size_label, calculating ); gtk_label_set_text( data->size_on_disk_label, calculating ); g_object_set_data( G_OBJECT( dlg ), "calc_size", data ); data->calc_size_thread = g_thread_create ( ( GThreadFunc ) calc_size, data, TRUE, NULL ); data->update_label_timer = g_timeout_add( 250, ( GSourceFunc ) on_update_labels, data ); } g_signal_connect( dlg, "response", G_CALLBACK(on_dlg_response), dlg ); g_signal_connect_swapped( gtk_builder_get_object(builder, "ok_button"), "clicked", G_CALLBACK(gtk_widget_destroy), dlg ); g_signal_connect_swapped( gtk_builder_get_object(builder, "cancel_button"), "clicked", G_CALLBACK(gtk_widget_destroy), dlg ); g_object_unref( builder ); gtk_notebook_set_current_page( notebook, page ); gtk_window_set_transient_for( GTK_WINDOW( dlg ), parent ); return dlg; }
liHttpHeaders* li_http_headers_new() { liHttpHeaders* headers = g_slice_new0(liHttpHeaders); g_queue_init(&headers->entries); return headers; }
gboolean gst_gl_mixer_process_textures (GstGLMixer * mix, GstBuffer * outbuf) { guint i; GList *walk; guint out_tex; gboolean res = TRUE; guint array_index = 0; GstVideoFrame out_frame; gboolean out_gl_wrapped = FALSE; GstElement *element = GST_ELEMENT (mix); GstVideoAggregator *vagg = GST_VIDEO_AGGREGATOR (mix); GstGLMixerClass *mix_class = GST_GL_MIXER_GET_CLASS (mix); GST_TRACE ("Processing buffers"); if (!gst_video_frame_map (&out_frame, &vagg->info, outbuf, GST_MAP_WRITE | GST_MAP_GL)) { return FALSE; } if (gst_is_gl_memory (out_frame.map[0].memory)) { out_tex = *(guint *) out_frame.data[0]; } else { GST_INFO ("Output Buffer does not contain correct memory, " "attempting to wrap for download"); out_tex = mix->out_tex_id;; if (!mix->download) mix->download = gst_gl_download_new (mix->context); gst_gl_download_set_format (mix->download, &out_frame.info); out_gl_wrapped = TRUE; } GST_OBJECT_LOCK (mix); walk = element->sinkpads; i = mix->frames->len; g_ptr_array_set_size (mix->frames, element->numsinkpads); for (; i < element->numsinkpads; i++) mix->frames->pdata[i] = g_slice_new0 (GstGLMixerFrameData); while (walk) { GstGLMixerPad *pad = GST_GL_MIXER_PAD (walk->data); GstVideoAggregatorPad *vaggpad = walk->data; GstGLMixerFrameData *frame; frame = g_ptr_array_index (mix->frames, array_index); frame->pad = pad; frame->texture = 0; walk = g_list_next (walk); if (vaggpad->buffer != NULL) { guint in_tex; if (!pad->upload) { pad->upload = gst_gl_upload_new (mix->context); gst_gl_upload_set_format (pad->upload, &vaggpad->info); } if (!gst_gl_upload_perform_with_buffer (pad->upload, vaggpad->buffer, &in_tex)) { ++array_index; pad->mapped = FALSE; continue; } pad->mapped = TRUE; frame->texture = in_tex; } ++array_index; } mix_class->process_textures (mix, mix->frames, out_tex); if (out_gl_wrapped) { if (!gst_gl_download_perform_with_data (mix->download, out_tex, out_frame.data)) { GST_ELEMENT_ERROR (mix, RESOURCE, NOT_FOUND, ("%s", "Failed to download video frame"), (NULL)); res = FALSE; goto out; } } out: i = 0; walk = GST_ELEMENT (mix)->sinkpads; while (walk) { GstGLMixerPad *pad = GST_GL_MIXER_PAD (walk->data); if (pad->mapped) gst_gl_upload_release_buffer (pad->upload); pad->mapped = FALSE; walk = g_list_next (walk); i++; } GST_OBJECT_UNLOCK (mix); gst_video_frame_unmap (&out_frame); return res; }
static void gst_media_descriptor_init (GstMediaDescriptor * self) { self->filenode = g_slice_new0 (FileNode); }
static gpointer _parse_atsc_mgt (GstMpegtsSection * section) { GstMpegtsAtscMGT *mgt = NULL; guint i = 0; guint8 *data, *end; guint16 descriptors_loop_length; mgt = g_slice_new0 (GstMpegtsAtscMGT); data = section->data; end = data + section->section_length; /* Skip already parsed data */ data += 8; mgt->protocol_version = GST_READ_UINT8 (data); data += 1; mgt->tables_defined = GST_READ_UINT16_BE (data); data += 2; mgt->tables = g_ptr_array_new_full (mgt->tables_defined, (GDestroyNotify) _gst_mpegts_atsc_mgt_table_free); for (i = 0; i < mgt->tables_defined && data + 11 < end; i++) { GstMpegtsAtscMGTTable *mgt_table; if (data + 11 >= end) { GST_WARNING ("MGT data too short to parse inner table num %d", i); goto error; } mgt_table = g_slice_new0 (GstMpegtsAtscMGTTable); g_ptr_array_add (mgt->tables, mgt_table); mgt_table->table_type = GST_READ_UINT16_BE (data); data += 2; mgt_table->pid = GST_READ_UINT16_BE (data) & 0x1FFF; data += 2; mgt_table->version_number = GST_READ_UINT8 (data) & 0x1F; data += 1; mgt_table->number_bytes = GST_READ_UINT32_BE (data); data += 4; descriptors_loop_length = GST_READ_UINT16_BE (data) & 0x0FFF; data += 2; if (data + descriptors_loop_length >= end) { GST_WARNING ("MGT data too short to parse inner table descriptors (table " "num %d", i); goto error; } mgt_table->descriptors = gst_mpegts_parse_descriptors (data, descriptors_loop_length); data += descriptors_loop_length; } descriptors_loop_length = GST_READ_UINT16_BE (data) & 0xFFF; data += 2; if (data + descriptors_loop_length >= end) { GST_WARNING ("MGT data too short to parse descriptors"); goto error; } mgt->descriptors = gst_mpegts_parse_descriptors (data, descriptors_loop_length); data += descriptors_loop_length; return (gpointer) mgt; error: _gst_mpegts_atsc_mgt_free (mgt); return NULL; }
void pragha_filter_dialog (PraghaApplication *pragha) { PraghaPlaylist *playlist; PraghaPreferences *preferences; GtkWidget *dialog, *scrollwin, *vbox, *search_entry; GtkWidget *filter_view = NULL; GtkListStore *filter_store; GtkTreeModel *filter_model; GtkCellRenderer *renderer; GtkTreeViewColumn *column; PraghaFilterDialog *fdialog; fdialog = g_slice_new0(PraghaFilterDialog); playlist = pragha_application_get_playlist (pragha); preferences = pragha_application_get_preferences (pragha); /* Crete the filter entry */ search_entry = pragha_search_entry_new(preferences); g_signal_connect (G_OBJECT(search_entry), "changed", G_CALLBACK(simple_filter_search_keyrelease_handler), fdialog); g_signal_connect (G_OBJECT(search_entry), "activate", G_CALLBACK(simple_filter_search_activate_handler), fdialog); /* Create the view */ filter_store = gtk_list_store_new (2, G_TYPE_UINT, G_TYPE_STRING); column = gtk_tree_view_column_new (); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_attributes (column, renderer, "text", 0, NULL); gtk_tree_view_column_set_spacing (column, 4); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_attributes (column, renderer, "markup", 1, NULL); gtk_tree_view_column_set_spacing (column, 4); /* Fill the filter tree view with current playlist */ pragha_filter_dialog_fill_model (filter_store, playlist); filter_model = gtk_tree_model_filter_new(GTK_TREE_MODEL(filter_store), NULL); g_object_unref(filter_store); gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(filter_model), (GtkTreeModelFilterVisibleFunc)filter_model_visible_func, fdialog, NULL); /* Create the tree view */ filter_view = gtk_tree_view_new_with_model(filter_model); gtk_tree_view_append_column (GTK_TREE_VIEW(filter_view), column); g_object_unref(G_OBJECT(filter_model)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW(filter_view), TRUE); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(filter_view), FALSE); gtk_tree_view_set_enable_search (GTK_TREE_VIEW(filter_view), FALSE); /* Store references */ fdialog->filter_view = filter_view; fdialog->filter_model = filter_model; fdialog->filter_string = NULL; fdialog->timeout_id = 0; fdialog->cplaylist = playlist; fdialog->preferences = pragha_preferences_get(); /* The search dialog */ dialog = gtk_dialog_new_with_buttons (_("Search in playlist"), GTK_WINDOW(pragha_application_get_window(pragha)), GTK_DIALOG_MODAL, GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, NULL); gtk_dialog_add_button (GTK_DIALOG (dialog), _("Add to playback queue"), GTK_RESPONSE_ACCEPT); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_JUMP_TO, GTK_RESPONSE_APPLY); gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 500); /* Add to the dialog's main vbox */ vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); gtk_box_pack_start (GTK_BOX(vbox), search_entry, FALSE, FALSE, 3); scrollwin = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER(scrollwin), filter_view); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(scrollwin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(scrollwin), GTK_SHADOW_IN); gtk_box_pack_start (GTK_BOX(vbox), scrollwin, TRUE, TRUE, 0); /* Connect signals */ g_signal_connect (filter_view, "row-activated", G_CALLBACK(pragha_filter_dialog_activated_cb), dialog); g_signal_connect (filter_view, "key_press_event", G_CALLBACK (pragha_filter_dialog_key_press), fdialog); g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(pragha_filter_dialog_response), fdialog); gtk_widget_show_all (dialog); }
static GPtrArray * _parse_atsc_mult_string (guint8 * data, guint datasize) { guint8 num_strings; GPtrArray *res = NULL; guint8 *end = data + datasize; gint i; if (datasize > 0) { /* 1 is the minimum entry size, so no need to check here */ num_strings = GST_READ_UINT8 (data); data += 1; res = g_ptr_array_new_full (num_strings, (GDestroyNotify) _gst_mpegts_atsc_mult_string_free); for (i = 0; i < num_strings; i++) { GstMpegtsAtscMultString *mstring; guint8 num_segments; gint j; mstring = g_slice_new0 (GstMpegtsAtscMultString); g_ptr_array_add (res, mstring); mstring->segments = g_ptr_array_new_full (num_strings, (GDestroyNotify) _gst_mpegts_atsc_string_segment_free); /* each entry needs at least 4 bytes (lang code and segments number) */ if (end - data < 4) { GST_WARNING ("Data too short for multstring parsing %d", (gint) (end - data)); goto error; } mstring->iso_639_langcode[0] = GST_READ_UINT8 (data); data += 1; mstring->iso_639_langcode[1] = GST_READ_UINT8 (data); data += 1; mstring->iso_639_langcode[2] = GST_READ_UINT8 (data); data += 1; num_segments = GST_READ_UINT8 (data); data += 1; for (j = 0; j < num_segments; j++) { GstMpegtsAtscStringSegment *seg; seg = g_slice_new0 (GstMpegtsAtscStringSegment); g_ptr_array_add (mstring->segments, seg); /* each entry needs at least 3 bytes */ if (end - data < 3) { GST_WARNING ("Data too short for multstring parsing %d", datasize); goto error; } seg->compression_type = GST_READ_UINT8 (data); data += 1; seg->mode = GST_READ_UINT8 (data); data += 1; seg->compressed_data_size = GST_READ_UINT8 (data); data += 1; if (end - data < seg->compressed_data_size) { GST_WARNING ("Data too short for multstring parsing %d", datasize); goto error; } if (seg->compressed_data_size) seg->compressed_data = data; data += seg->compressed_data_size; } } } return res; error: if (res) g_ptr_array_unref (res); return NULL; }
static void uridecodebin_pad_added_cb (GstElement * uridecodebin, GstPad * pad, GstDiscoverer * dc) { PrivateStream *ps; GstPad *sinkpad = NULL; GstCaps *caps; static GstCaps *subs_caps = NULL; if (!subs_caps) { subs_caps = gst_caps_from_string ("text/plain; text/x-pango-markup; " "subpicture/x-pgs; subpicture/x-dvb; application/x-subtitle-unknown; " "application/x-ssa; application/x-ass; subtitle/x-kate; " "video/x-dvd-subpicture; "); } GST_DEBUG_OBJECT (dc, "pad %s:%s", GST_DEBUG_PAD_NAME (pad)); ps = g_slice_new0 (PrivateStream); ps->dc = dc; ps->pad = pad; ps->queue = gst_element_factory_make ("queue", NULL); ps->sink = gst_element_factory_make ("fakesink", NULL); if (G_UNLIKELY (ps->queue == NULL || ps->sink == NULL)) goto error; g_object_set (ps->sink, "silent", TRUE, NULL); g_object_set (ps->queue, "max-size-buffers", 1, "silent", TRUE, NULL); caps = gst_pad_get_caps_reffed (pad); if (gst_caps_can_intersect (caps, subs_caps)) { /* Subtitle streams are sparse and don't provide any information - don't * wait for data to preroll */ g_object_set (ps->sink, "async", FALSE, NULL); } gst_caps_unref (caps); gst_bin_add_many (dc->priv->pipeline, ps->queue, ps->sink, NULL); if (!gst_element_link_pads_full (ps->queue, "src", ps->sink, "sink", GST_PAD_LINK_CHECK_NOTHING)) goto error; if (!gst_element_sync_state_with_parent (ps->sink)) goto error; if (!gst_element_sync_state_with_parent (ps->queue)) goto error; sinkpad = gst_element_get_static_pad (ps->queue, "sink"); if (sinkpad == NULL) goto error; if (gst_pad_link_full (pad, sinkpad, GST_PAD_LINK_CHECK_NOTHING) != GST_PAD_LINK_OK) goto error; gst_object_unref (sinkpad); /* Add an event probe */ gst_pad_add_event_probe (pad, G_CALLBACK (_event_probe), ps); DISCO_LOCK (dc); dc->priv->streams = g_list_append (dc->priv->streams, ps); DISCO_UNLOCK (dc); GST_DEBUG_OBJECT (dc, "Done handling pad"); return; error: GST_ERROR_OBJECT (dc, "Error while handling pad"); if (sinkpad) gst_object_unref (sinkpad); if (ps->queue) gst_object_unref (ps->queue); if (ps->sink) gst_object_unref (ps->sink); g_slice_free (PrivateStream, ps); return; }
static gpointer _parse_atsc_vct (GstMpegtsSection * section) { GstMpegtsAtscVCT *vct = NULL; guint8 *data, *end, source_nb; guint32 tmp32; guint16 descriptors_loop_length, tmp16; guint i; GError *err = NULL; vct = g_slice_new0 (GstMpegtsAtscVCT); data = section->data; end = data + section->section_length; vct->transport_stream_id = section->subtable_extension; /* Skip already parsed data */ data += 8; /* minimum size */ if (end - data < 2 + 2 + 4) goto error; vct->protocol_version = *data; data += 1; source_nb = *data; data += 1; vct->sources = g_ptr_array_new_full (source_nb, (GDestroyNotify) _gst_mpegts_atsc_vct_source_free); for (i = 0; i < source_nb; i++) { GstMpegtsAtscVCTSource *source; /* minimum 32 bytes for a entry, 2 bytes second descriptor loop-length, 4 bytes crc */ if (end - data < 32 + 2 + 4) goto error; source = g_slice_new0 (GstMpegtsAtscVCTSource); g_ptr_array_add (vct->sources, source); source->short_name = g_convert ((gchar *) data, 14, "utf-8", "utf-16be", NULL, NULL, &err); if (err) { GST_WARNING ("Failed to convert VCT Source short_name to utf-8: %d %s", err->code, err->message); GST_MEMDUMP ("UTF-16 string", data, 14); g_error_free (err); } data += 14; tmp32 = GST_READ_UINT32_BE (data); source->major_channel_number = (tmp32 >> 18) & 0x03FF; source->minor_channel_number = (tmp32 >> 8) & 0x03FF; source->modulation_mode = tmp32 & 0xF; data += 4; source->carrier_frequency = GST_READ_UINT32_BE (data); data += 4; source->channel_TSID = GST_READ_UINT16_BE (data); data += 2; source->program_number = GST_READ_UINT16_BE (data); data += 2; tmp16 = GST_READ_UINT16_BE (data); source->ETM_location = (tmp16 >> 14) & 0x3; source->access_controlled = (tmp16 >> 13) & 0x1; source->hidden = (tmp16 >> 12) & 0x1; /* only used in CVCT */ source->path_select = (tmp16 >> 11) & 0x1; source->out_of_band = (tmp16 >> 10) & 0x1; source->hide_guide = (tmp16 >> 9) & 0x1; source->service_type = tmp16 & 0x3f; data += 2; source->source_id = GST_READ_UINT16_BE (data); data += 2; descriptors_loop_length = GST_READ_UINT16_BE (data) & 0x03FF; data += 2; if (end - data < descriptors_loop_length + 6) goto error; source->descriptors = gst_mpegts_parse_descriptors (data, descriptors_loop_length); if (source->descriptors == NULL) goto error; data += descriptors_loop_length; } descriptors_loop_length = GST_READ_UINT16_BE (data) & 0x03FF; data += 2; if (end - data < descriptors_loop_length + 4) goto error; vct->descriptors = gst_mpegts_parse_descriptors (data, descriptors_loop_length); if (vct->descriptors == NULL) goto error; data += descriptors_loop_length; return (gpointer) vct; error: _gst_mpegts_atsc_vct_free (vct); return NULL; }
static void starter_instance_init (Starter* wcm) { GtkWidget *main_box; GtkWidget *alignment; GtkWidget *vbox1, *vbox2, *vbox; GtkWidget *hbox; GtkWidget *label; GError *error = NULL; gchar *logo; gchar *aux; const guint logo_offset = 20; wcm->priv = g_slice_new0 (StarterPrivate); wcm->priv->filename = g_strdup (_("Starter")); logo = g_build_filename (PACKAGE_PIXMAPS_DIR, LOGO_NAME, NULL); wcm->priv->logo = gdk_pixbuf_new_from_file (logo, &error); if (error != NULL) { g_warning ("%s", error->message); g_error_free (error); return; } wcm->priv->event_box = gtk_event_box_new (); gtk_widget_show (wcm->priv->event_box); g_signal_connect (wcm->priv->event_box, "expose-event", G_CALLBACK (on_expose_event_cb), wcm); alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), logo_offset + gdk_pixbuf_get_height (wcm->priv->logo) + logo_offset, 0, logo_offset, 0); gtk_widget_show (alignment); gtk_container_add (GTK_CONTAINER (wcm->priv->event_box), alignment); main_box = gtk_hbox_new (FALSE, 35); gtk_widget_show (main_box); gtk_container_add (GTK_CONTAINER (alignment), main_box); /* * vbox1 */ vbox1 = gtk_vbox_new (FALSE, 6); gtk_widget_show (vbox1); gtk_box_pack_start (GTK_BOX (main_box), vbox1, FALSE, FALSE, 0); /* * FILE/PROJECT */ label = gtk_label_new (NULL); aux = get_header_text (_("Create File/Project")); gtk_label_set_markup (GTK_LABEL (label), aux); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); g_free (aux); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (vbox1), label, FALSE, FALSE, 0); hbox = gtk_hbox_new (FALSE, 6); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox1), hbox, FALSE, FALSE, 0); label = gtk_label_new (" "); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); wcm->priv->file_box = gtk_vbox_new (FALSE, 6); gtk_widget_show (wcm->priv->file_box); gtk_box_pack_start (GTK_BOX (hbox), wcm->priv->file_box, FALSE, FALSE, 0); wcm->priv->new_file = anjuta_starter_button_new (_("New File")); gtk_widget_show (wcm->priv->new_file); gtk_box_pack_start (GTK_BOX (wcm->priv->file_box), wcm->priv->new_file, TRUE, TRUE, 0); g_signal_connect (wcm->priv->new_file, "clicked", G_CALLBACK (new_file_clicked_cb), wcm); /* Separator */ label = gtk_label_new (""); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (vbox1), label, FALSE, FALSE, 0); /* * Recent Projects */ label = gtk_label_new (NULL); aux = get_header_text (_("Recent Projects")); gtk_label_set_markup (GTK_LABEL (label), aux); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); g_free (aux); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (vbox1), label, FALSE, FALSE, 0); hbox = gtk_hbox_new (FALSE, 6); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox1), hbox, FALSE, FALSE, 0); label = gtk_label_new (" "); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); wcm->priv->recent_projects = gtk_vbox_new (FALSE, 0); gtk_widget_show (wcm->priv->recent_projects); gtk_box_pack_start (GTK_BOX (hbox), wcm->priv->recent_projects, FALSE, FALSE, 0); build_recent_projects (wcm->priv->recent_projects, wcm); /* * vbox2 */ vbox2 = gtk_vbox_new (FALSE, 6); gtk_widget_show (vbox2); gtk_box_pack_start (GTK_BOX (main_box), vbox2, FALSE, FALSE, 0); /* * Links */ label = gtk_label_new (NULL); aux = get_header_text (_("Links")); gtk_label_set_markup (GTK_LABEL (label), aux); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); g_free (aux); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0); hbox = gtk_hbox_new (FALSE, 6); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0); label = gtk_label_new (" "); gtk_widget_show (label); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); vbox = gtk_vbox_new (FALSE, 6); gtk_widget_show (vbox); gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0); wcm->priv->anjuta_page = anjuta_starter_button_new (_("Anjuta Home Page")); gtk_widget_show (wcm->priv->anjuta_page); gtk_box_pack_start (GTK_BOX (vbox), wcm->priv->anjuta_page, TRUE, TRUE, 0); g_signal_connect (wcm->priv->anjuta_page, "clicked", G_CALLBACK (anjuta_page_clicked_cb), NULL); wcm->priv->anjuta_manual = anjuta_starter_button_new (_("Anjuta Manual")); gtk_widget_show (wcm->priv->anjuta_manual); gtk_box_pack_start (GTK_BOX (vbox), wcm->priv->anjuta_manual, TRUE, TRUE, 0); g_signal_connect (wcm->priv->anjuta_manual, "clicked", G_CALLBACK (anjuta_manual_clicked_cb), NULL); wcm->priv->gnome_library = anjuta_starter_button_new (_("GNOME Online API Documentation")); gtk_widget_show (wcm->priv->gnome_library); gtk_box_pack_start (GTK_BOX (vbox), wcm->priv->gnome_library, TRUE, TRUE, 0); g_signal_connect (wcm->priv->gnome_library, "clicked", G_CALLBACK (gnome_library_clicked_cb), NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (wcm), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); }
static void initiate_authentication(PolkitAgentListener *listener, const gchar *action_id, const gchar *message, const gchar *icon_name, PolkitDetails *details, const gchar *cookie, GList *identities, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GtkWidget *content; GtkWidget *combo_label; GtkWidget *grid; AuthDlgData *d = g_slice_new0(AuthDlgData); char** p; for(p = polkit_details_get_keys(details); *p; ++p) g_debug("initiate_authentication: %s: %s", *p, polkit_details_lookup(details, *p)); d->task = g_task_new(listener, cancellable, callback, user_data); d->cancellable = cancellable; d->action_id = g_strdup(action_id); d->cookie = g_strdup(cookie); d->auth_dlg = xfce_titled_dialog_new_with_buttons( "Authentication required", NULL, GTK_DIALOG_DESTROY_WITH_PARENT, "_Deny", GTK_RESPONSE_CANCEL, "_Allow", GTK_RESPONSE_OK, NULL); xfce_titled_dialog_set_subtitle(XFCE_TITLED_DIALOG(d->auth_dlg), message); gtk_window_set_icon_name(GTK_WINDOW(d->auth_dlg), "dialog-password"); content = gtk_dialog_get_content_area(GTK_DIALOG(d->auth_dlg)); combo_label = gtk_label_new("Identity:"); gtk_widget_set_halign(combo_label, GTK_ALIGN_END); gtk_widget_show(combo_label); d->id_combo = gtk_combo_box_new(); add_identities(GTK_COMBO_BOX(d->id_combo), identities); g_signal_connect(d->id_combo, "changed", G_CALLBACK(on_id_combo_user_changed), d); gtk_combo_box_set_active(GTK_COMBO_BOX(d->id_combo), 0); gtk_widget_set_hexpand(d->id_combo, TRUE); gtk_widget_show(d->id_combo); d->entry_label = gtk_label_new(NULL); gtk_widget_set_halign(d->entry_label, GTK_ALIGN_END); gtk_widget_show(d->entry_label); d->entry = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(d->entry), FALSE); gtk_widget_set_hexpand(d->entry, TRUE); gtk_widget_show(d->entry); g_signal_connect (d->entry, "activate", G_CALLBACK(on_entry_activate), d); grid = grid2x2(combo_label, d->id_combo, d->entry_label, d->entry); gtk_box_pack_start(GTK_BOX(content), grid, TRUE, TRUE, 0); d->status = gtk_label_new(NULL); gtk_box_pack_start(GTK_BOX(content), d->status, TRUE, TRUE, 0); gtk_widget_show(d->status); g_signal_connect(cancellable, "cancelled", G_CALLBACK(on_cancelled), d); g_signal_connect(d->auth_dlg, "response", G_CALLBACK(on_auth_dlg_response), d); gtk_widget_grab_focus(d->entry); gtk_window_present(GTK_WINDOW(d->auth_dlg)); }
FspData* fsp_data_new (FspDataType type) { FspData *new_data = NULL; g_return_val_if_fail ((type > FSP_UNKNOWN) && (type < FSP_DATA_LAST), NULL); new_data = g_slice_new0 (FspData); new_data->type = type; switch (type) { case FSP_AUTH_TOKEN: new_data->auth_token.token = NULL; new_data->auth_token.token_secret = NULL; new_data->auth_token.permissions = NULL; new_data->auth_token.nsid = NULL; new_data->auth_token.username = NULL; new_data->auth_token.fullname = NULL; break; case FSP_UPLOAD_STATUS: new_data->upload_status.id = NULL; new_data->upload_status.username = NULL; new_data->upload_status.pro_user = FALSE; new_data->upload_status.bw_max_kb = G_MAXUINT32; new_data->upload_status.bw_used_kb = G_MAXUINT32; new_data->upload_status.bw_used_videos = G_MAXUINT; new_data->upload_status.bw_remaining_videos = G_MAXUINT; new_data->upload_status.bw_remaining_kb = G_MAXUINT32; new_data->upload_status.picture_fs_max_kb = G_MAXUINT32; new_data->upload_status.video_fs_max_kb = G_MAXUINT32; break; case FSP_PHOTO_INFO: new_data->photo_info.id = NULL; new_data->photo_info.secret = NULL; new_data->photo_info.server = NULL; new_data->photo_info.is_favorite = FALSE; new_data->photo_info.license = FSP_LICENSE_NONE; new_data->photo_info.rotation = FSP_ROTATION_NONE; new_data->photo_info.orig_secret = NULL; new_data->photo_info.orig_format = NULL; new_data->photo_info.title = NULL; new_data->photo_info.description = NULL; new_data->photo_info.is_public = FSP_VISIBILITY_NONE; new_data->photo_info.is_family = FSP_VISIBILITY_NONE; new_data->photo_info.is_friend = FSP_VISIBILITY_NONE; new_data->photo_info.perm_comment = FSP_PERMISSION_UNKNOWN; new_data->photo_info.perm_add_meta = FSP_PERMISSION_UNKNOWN; new_data->photo_info.can_comment = FSP_PERMISSION_UNKNOWN; new_data->photo_info.can_add_meta = FSP_PERMISSION_UNKNOWN; break; case FSP_PHOTO_SET: new_data->photo_set.id = NULL; new_data->photo_set.title = NULL; new_data->photo_set.description = NULL; new_data->photo_set.primary_photo_id = NULL; new_data->photo_set.n_photos = -1; break; case FSP_GROUP: new_data->group.id = NULL; new_data->group.name = NULL; new_data->group.privacy = FSP_GROUP_PRIVACY_NONE; new_data->group.n_photos = -1; break; case FSP_LOCATION: new_data->location.latitude = 0.0; new_data->location.longitude = 0.0; new_data->location.accuracy = 16; new_data->location.context = FSP_LOCATION_CONTEXT_UNKNOWN; break; default: break; } return new_data; }
static ListedService * listed_service_new (void) { return g_slice_new0 (ListedService); }
static void start_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attr_names, const gchar **attr_values, gpointer user_data, GError **error) { DeskmenuObject *dm_object = user_data; DeskmenuElementType element_type; const gchar **ncursor = attr_names, **vcursor = attr_values; GtkWidget *item, *menu; gint w, h; element_type = GPOINTER_TO_INT (g_hash_table_lookup (element_hash, element_name)); if ((dm_object->menu && !dm_object->current_menu) || (!dm_object->menu && element_type != DESKMENU_ELEMENT_MENU)) { gint line_num, char_num; g_markup_parse_context_get_position (context, &line_num, &char_num); g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, "Error on line %d char %d: Element '%s' declared outside of " "toplevel menu element", line_num, char_num, element_name); return; } switch (element_type) { case DESKMENU_ELEMENT_MENU: if (dm_object->current_item != NULL) { gint line_num, char_num; g_markup_parse_context_get_position (context, &line_num, &char_num); g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, "Error on line %d char %d: Element 'menu' cannot be nested " "inside of an item element", line_num, char_num); return; } if (!dm_object->menu) { /*if (strcmp (*ncursor, "size") == 0) { deskmenu->w = g_strdup (*vcursor); deskmenu->h = g_strdup (*vcursor); } else { gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, deskmenu->w, deskmenu->h); }*/ dm_object->menu = gtk_menu_new (); g_object_set_data (G_OBJECT (dm_object->menu), "parent menu", NULL); dm_object->current_menu = dm_object->menu; } else { gchar *name = NULL; gchar *icon = NULL; gboolean name_exec = FALSE; gboolean icon_file = FALSE; while (*ncursor) { if (strcmp (*ncursor, "name") == 0) name = g_strdup (*vcursor); else if (strcmp (*ncursor, "icon") == 0) icon = g_strdup (*vcursor); else if ((strcmp (*ncursor, "mode") == 0) && (strcmp (*vcursor, "exec") == 0)) name_exec = TRUE; else if ((strcmp (*ncursor, "mode1") == 0) && (strcmp (*vcursor, "file") == 0)) icon_file = TRUE; else g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "Unknown attribute: %s", *ncursor); ncursor++; vcursor++; } if (name_exec) { GtkWidget *label; GHook *hook; item = gtk_image_menu_item_new (); label = gtk_label_new_with_mnemonic (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); g_object_set_data (G_OBJECT (label), "exec", g_strdup (name)); gtk_container_add (GTK_CONTAINER (item), label); hook = g_hook_alloc (dm_object->show_hooks); hook->data = (gpointer) label; hook->func = (GHookFunc *) launcher_name_exec_update; g_hook_append (dm_object->show_hooks, hook); } else { if (name) item = gtk_image_menu_item_new_with_mnemonic (name); else item = gtk_image_menu_item_new_with_mnemonic (""); } if (icon) { if (icon_file) { gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(item), gtk_image_new_from_pixbuf (gdk_pixbuf_new_from_file_at_size (parse_expand_tilde(icon), w, h, NULL))); } else { gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU)); } } gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), item); menu = gtk_menu_new (); g_object_set_data (G_OBJECT (menu), "parent menu", dm_object->current_menu); dm_object->current_menu = menu; gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), dm_object->current_menu); if (!dm_object->make_from_pipe) { GtkWidget *pin = gtk_tearoff_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), pin); //add a pin menu item dm_object->pin_items = g_slist_prepend (dm_object->pin_items, pin); } else { if (gtk_menu_get_tearoff_state (GTK_MENU(dm_object->menu))) { GtkWidget *pin = gtk_tearoff_menu_item_new(); gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), pin); //add a pin menu item } } g_free (name); g_free (icon); } break; case DESKMENU_ELEMENT_SEPARATOR: if (dm_object->current_item != NULL) { gint line_num, char_num; g_markup_parse_context_get_position (context, &line_num, &char_num); g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, "Error on line %d char %d: Element 'menu' cannot be nested " "inside of an item element", line_num, char_num); return; } else { gchar *name = NULL; gchar *icon = NULL; gboolean name_exec = FALSE; gboolean icon_file = FALSE; gboolean decorate = FALSE; gint w, h; item = gtk_separator_menu_item_new(); while (*ncursor) { if (strcmp (*ncursor, "name") == 0) { name = g_strdup (*vcursor); if (!decorate) { decorate = TRUE; } } else if (strcmp (*ncursor, "icon") == 0) { icon = g_strdup (*vcursor); if (!decorate) { decorate = TRUE; } } else if ((strcmp (*ncursor, "mode") == 0) && (strcmp (*vcursor, "exec") == 0)) name_exec = TRUE; else if ((strcmp (*ncursor, "mode1") == 0) && (strcmp (*vcursor, "file") == 0)) icon_file = TRUE; else g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "Unknown attribute: %s", *ncursor); ncursor++; vcursor++; } if (decorate) { GtkWidget *box = gtk_hbox_new (FALSE, 3); gtk_container_add (GTK_CONTAINER(item), GTK_WIDGET(box)); if (name_exec) { GtkWidget *label; GHook *hook; label = gtk_label_new_with_mnemonic (NULL); g_object_set_data (G_OBJECT (label), "exec", g_strdup (name)); gtk_box_pack_end (GTK_BOX(box), label, TRUE, FALSE, 0); hook = g_hook_alloc (dm_object->show_hooks); hook->data = (gpointer) label; hook->func = (GHookFunc *) launcher_name_exec_update; g_hook_append (dm_object->show_hooks, hook); } else { gtk_box_pack_end (GTK_BOX(box), gtk_label_new_with_mnemonic (name), TRUE, FALSE, 0); } if (icon) { GtkWidget *image; if (icon_file) { gtk_icon_size_lookup (GTK_ICON_SIZE_MENU, &w, &h); image = gtk_image_new_from_pixbuf (gdk_pixbuf_new_from_file_at_size (parse_expand_tilde(icon), w, h, NULL)); } else { image = gtk_image_new_from_icon_name (icon, GTK_ICON_SIZE_MENU); } gtk_box_pack_start (GTK_BOX(box), image, FALSE, FALSE, 0); } gtk_widget_set_state (item, GTK_STATE_PRELIGHT); /*derive colors from menu hover*/ g_free (name); g_free (icon); } gtk_menu_shell_append (GTK_MENU_SHELL (dm_object->current_menu), item); } break; case DESKMENU_ELEMENT_ITEM: if (dm_object->current_item != NULL) { gint line_num, char_num; g_markup_parse_context_get_position (context, &line_num, &char_num); g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE, "Error on line %d char %d: Element 'item' cannot be nested " "inside of another item element", line_num, char_num); return; } dm_object->current_item = g_slice_new0 (DeskmenuItem); while (*ncursor) { if (strcmp (*ncursor, "type") == 0) dm_object->current_item->type = GPOINTER_TO_INT (g_hash_table_lookup (item_hash, *vcursor)); else g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ATTRIBUTE, "Unknown attribute: %s", *ncursor); ncursor++; vcursor++; } break; case DESKMENU_ELEMENT_NAME: while (*ncursor) { if ((strcmp (*ncursor, "mode") == 0) && (strcmp (*vcursor, "exec") == 0)) dm_object->current_item->name_exec = TRUE; ncursor++; vcursor++; } /* no break here to let it fall through */ case DESKMENU_ELEMENT_ICON: while (*ncursor) { if ((strcmp (*ncursor, "mode1") == 0) && (strcmp (*vcursor, "file") == 0)) dm_object->current_item->icon_file = TRUE; ncursor++; vcursor++; } /* no break here to let it fall through */ case DESKMENU_ELEMENT_VPICON: while (*ncursor) { if ((strcmp (*ncursor, "mode1") == 0) && (strcmp (*vcursor, "file") == 0)) dm_object->current_item->vpicon_file = TRUE; ncursor++; vcursor++; } /* no break here to let it fall through */ case DESKMENU_ELEMENT_COMMAND: while (*ncursor) { if ((strcmp (*ncursor, "mode2") == 0) && (strcmp (*vcursor, "pipe") == 0)) dm_object->current_item->command_pipe = TRUE; if (dm_object->current_item->command_pipe == TRUE && (strcmp (*ncursor, "cache") == 0) && (strcmp (*vcursor, "true") == 0)) dm_object->current_item->cache_output = TRUE; ncursor++; vcursor++; } /* no break here to let it fall through */ case DESKMENU_ELEMENT_WRAP: if (dm_object->current_item) dm_object->current_item->current_element = element_type; break; case DESKMENU_ELEMENT_THISVP: if (dm_object->current_item) dm_object->current_item->current_element = element_type; break; case DESKMENU_ELEMENT_MINIONLY: if (dm_object->current_item) dm_object->current_item->current_element = element_type; break; case DESKMENU_ELEMENT_QUANTITY: if (dm_object->current_item) dm_object->current_item->current_element = element_type; break; case DESKMENU_ELEMENT_SORT: if (dm_object->current_item) dm_object->current_item->current_element = element_type; break; case DESKMENU_ELEMENT_AGE: if (dm_object->current_item) dm_object->current_item->current_element = element_type; break; default: g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT, "Unknown element: %s", element_name); break; } }
static GstFlowReturn new_sample_post_handler (GstElement * appsink, gpointer user_data) { GstElement *appsrc = GST_ELEMENT (user_data); GstSample *sample = NULL; GstBuffer *buffer; GstFlowReturn ret; GstClockTime *base_time; g_signal_emit_by_name (appsink, "pull-sample", &sample); if (sample == NULL) return GST_FLOW_OK; buffer = gst_sample_get_buffer (sample); if (buffer == NULL) { ret = GST_FLOW_OK; goto end; } gst_buffer_ref (buffer); buffer = gst_buffer_make_writable (buffer); BASE_TIME_LOCK (GST_OBJECT_PARENT (appsrc)); base_time = g_object_get_qdata (G_OBJECT (GST_OBJECT_PARENT (appsrc)), base_time_data_quark ()); if (base_time == NULL) { GstClock *clock; clock = gst_element_get_clock (appsrc); base_time = g_slice_new0 (GstClockTime); g_object_set_qdata_full (G_OBJECT (GST_OBJECT_PARENT (appsrc)), base_time_data_quark (), base_time, release_gst_clock); *base_time = gst_clock_get_time (clock) - gst_element_get_base_time (appsrc); g_object_unref (clock); GST_DEBUG ("Setting base time to: %" G_GUINT64_FORMAT, *base_time); } if (GST_BUFFER_PTS_IS_VALID (buffer)) buffer->pts += *base_time; if (GST_BUFFER_DTS_IS_VALID (buffer)) buffer->dts += *base_time; BASE_TIME_UNLOCK (GST_OBJECT_PARENT (appsrc)); /* Pass the buffer through appsrc element which is */ /* placed in a different pipeline */ g_signal_emit_by_name (appsrc, "push-buffer", buffer, &ret); gst_buffer_unref (buffer); if (ret != GST_FLOW_OK) { /* something went wrong */ GST_ERROR ("Could not send buffer to appsrc %s. Cause %s", GST_ELEMENT_NAME (appsrc), gst_flow_get_name (ret)); } end: if (sample != NULL) gst_sample_unref (sample); return ret; }
/** * fs_codec_list_from_keyfile * @filename: Name of the #GKeyFile to read the codecs parameters from * @error: location of a #GError, or NULL if no error occured * * Reads the content of a #GKeyFile of the following format into * a #GList of #FsCodec structures. * * * Example: * |[ * [audio/codec1] * clock-rate=8000 * * [audio/codec1:1] * clock-rate=16000 * * [audio/codec2] * one_param=QCIF * another_param=WOW * ]| * * Return value: The #GList of #FsCodec or %NULL if the keyfile was empty * or an error occured. */ GList * fs_codec_list_from_keyfile (const gchar *filename, GError **error) { GKeyFile *keyfile = NULL; GList *codecs = NULL; GError *gerror = NULL; gchar **groups = NULL; gsize groups_count = 0; int i; g_assert (filename); keyfile = g_key_file_new (); if (!g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_NONE, error)) { goto out; } groups = g_key_file_get_groups (keyfile, &groups_count); if (!groups) goto out; for (i=0; i < groups_count && groups[i]; i++) { FsCodec *codec = g_slice_new0 (FsCodec); gchar **keys = NULL; gsize keys_count; int j; gchar *encoding_name = NULL; gchar *next_tok = NULL; codec->id = FS_CODEC_ID_ANY; keys = g_key_file_get_keys (keyfile, groups[i], &keys_count, &gerror); if (!keys || gerror) { if (gerror) { GST_WARNING ("Unable to read parameters for %s: %s\n", groups[i], gerror->message); } else { GST_WARNING ("Unknown errors while reading parameters for %s", groups[i]); } g_clear_error (&gerror); goto next_codec; } next_tok = strchr (groups[i], '/'); if (!next_tok) { GST_WARNING ("Invalid codec name: %s", groups[i]); goto next_codec; } if ((next_tok - groups[i]) == 5 /* strlen ("audio") */ && !g_ascii_strncasecmp ("audio", groups[i], 5)) codec->media_type = FS_MEDIA_TYPE_AUDIO; else if ((next_tok - groups[i]) == 5 /* strlen ("video") */ && !g_ascii_strncasecmp ("video", groups[i], 5)) codec->media_type = FS_MEDIA_TYPE_VIDEO; else { GST_WARNING ("Invalid media type in codec name name %s", groups[i]); goto next_codec; } encoding_name = next_tok+1; next_tok = strchr (groups[i], ':'); if (next_tok) { codec->encoding_name = g_strndup (encoding_name, next_tok - encoding_name); } else { codec->encoding_name = g_strdup (encoding_name); } if (!codec->encoding_name || codec->encoding_name[0] == 0) { goto next_codec; } for (j = 0; j < keys_count && keys[j]; j++) { if (!strcmp ("clock-rate", keys[j])) { codec->clock_rate = g_key_file_get_integer (keyfile, groups[i], keys[j], &gerror); if (gerror) { codec->clock_rate = 0; goto keyerror; } } else if (!strcmp ("id", keys[j])) { codec->id = g_key_file_get_integer (keyfile, groups[i], keys[j], &gerror); if (gerror) { codec->id = FS_CODEC_ID_ANY; goto keyerror; } if (codec->id < 0) codec->id = FS_CODEC_ID_DISABLE; } else if (!strcmp ("channels", keys[j])) { codec->channels = g_key_file_get_integer (keyfile, groups[i], keys[j], &gerror); if (gerror) { codec->channels = 0; goto keyerror; } } else { FsCodecParameter *param = g_slice_new (FsCodecParameter); param->name = g_strdup (keys[j]); param->value = g_key_file_get_string (keyfile, groups[i], keys[j], &gerror); if (gerror) { g_free (param->name); g_free (param->value); g_slice_free (FsCodecParameter, param); goto keyerror; } if (!param->name || !param->value) { g_free (param->name); g_free (param->value); g_slice_free (FsCodecParameter, param); } else { codec->optional_params = g_list_append (codec->optional_params, param); } } continue; keyerror: GST_WARNING ("Error reading key %s codec %s: %s", keys[j], groups[i], gerror->message); g_clear_error (&gerror); } codecs = g_list_append (codecs, codec); g_strfreev (keys); continue; next_codec: fs_codec_destroy (codec); g_strfreev (keys); } out: g_strfreev (groups); g_key_file_free (keyfile); return codecs; }
EAPMethodTTLS * eap_method_ttls_new (const char *glade_file, WirelessSecurity *parent, NMConnection *connection) { EAPMethodTTLS *method; GtkWidget *widget; GladeXML *xml; GtkFileFilter *filter; NMSetting8021x *s_8021x = NULL; const char *filename; g_return_val_if_fail (glade_file != NULL, NULL); xml = glade_xml_new (glade_file, "eap_ttls_notebook", NULL); if (xml == NULL) { g_warning ("Couldn't get eap_ttls_widget from glade xml"); return NULL; } widget = glade_xml_get_widget (xml, "eap_ttls_notebook"); g_assert (widget); g_object_ref_sink (widget); method = g_slice_new0 (EAPMethodTTLS); if (!method) { g_object_unref (xml); g_object_unref (widget); return NULL; } eap_method_init (EAP_METHOD (method), validate, add_to_size_group, fill_connection, destroy, xml, widget, "eap_ttls_anon_identity_entry"); eap_method_nag_init (EAP_METHOD (method), glade_file, "eap_ttls_ca_cert_button", connection); method->sec_parent = parent; if (connection) s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X)); widget = glade_xml_get_widget (xml, "eap_ttls_ca_cert_button"); g_assert (widget); gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), TRUE); gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (widget), _("Choose a Certificate Authority certificate...")); g_signal_connect (G_OBJECT (widget), "selection-changed", (GCallback) wireless_security_changed_cb, parent); filter = eap_method_default_file_chooser_filter_new (FALSE); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget), filter); if (connection) { filename = g_object_get_data (G_OBJECT (connection), NMA_PATH_CA_CERT_TAG); if (filename) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename); } widget = glade_xml_get_widget (xml, "eap_ttls_anon_identity_entry"); if (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x)) gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_anonymous_identity (s_8021x)); g_signal_connect (G_OBJECT (widget), "changed", (GCallback) wireless_security_changed_cb, parent); widget = inner_auth_combo_init (method, glade_file, connection, s_8021x); inner_auth_combo_changed_cb (widget, (gpointer) method); return method; }
static void grl_raitv_source_resolve (GrlSource *source, GrlSourceResolveSpec *rs) { gchar *urltarget; GrlRaitvSource *self = GRL_RAITV_SOURCE (source); RaitvOperation *op; RaitvMediaType mediatype; GRL_DEBUG ("Starting resolve source: url=%s",grl_media_get_url (rs->media)); if (!GRL_IS_MEDIA_VIDEO (rs->media) && !GRL_IS_MEDIA_BOX (rs->media)) { rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL); return; } mediatype = classify_media_id (grl_media_get_id (rs->media)); switch (mediatype) { case RAITV_MEDIA_TYPE_ROOT: rs->media = produce_container_from_directory (rs->media, NULL, 0, mediatype); break; case RAITV_MEDIA_TYPE_POPULARS: rs->media = produce_container_from_directory (rs->media, root_dir, ROOT_DIR_POPULARS_INDEX, mediatype); break; case RAITV_MEDIA_TYPE_RECENTS: rs->media = produce_container_from_directory (rs->media, root_dir, ROOT_DIR_RECENTS_INDEX, mediatype); break; case RAITV_MEDIA_TYPE_POPULAR_THEME: case RAITV_MEDIA_TYPE_RECENT_THEME: rs->media = produce_container_from_directory (rs->media, themes_dir, get_theme_index_from_id (grl_media_get_id (rs->media)), mediatype); break; case RAITV_MEDIA_TYPE_VIDEO: op = g_slice_new0 (RaitvOperation); op->source = g_object_ref (source); op->cancellable = g_cancellable_new (); op->operation_id = rs->operation_id; op->resolveCb = rs->callback; op->user_data = rs->user_data; op->media = rs->media; grl_operation_set_data (rs->operation_id, op); urltarget = g_strdup_printf ("http://www.rai.tv/dl/RaiTV/programmi/media/%s.html", grl_media_get_id(rs->media)); GRL_DEBUG ("Opening '%s'", urltarget); grl_net_wc_request_async (self->priv->wc, urltarget, op->cancellable, proxy_call_resolve_grlnet_async_cb, op); g_free(urltarget); return; } rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL); return; if ( grl_media_get_url (rs->media) != NULL) { rs->callback (rs->source, rs->operation_id, rs->media, rs->user_data, NULL); return; } op = g_slice_new0 (RaitvOperation); op->source = g_object_ref (source); op->cancellable = g_cancellable_new (); op->operation_id = rs->operation_id; op->resolveCb = rs->callback; op->user_data = rs->user_data; op->media = rs->media; grl_operation_set_data (rs->operation_id, op); urltarget = g_strdup_printf("%s/%s.html","http://www.rai.tv/dl/RaiTV/programmi/media",grl_media_get_id(rs->media)); GRL_DEBUG ("Opening '%s'", urltarget); grl_net_wc_request_async (self->priv->wc, urltarget, op->cancellable, proxy_call_resolve_grlnet_async_cb, op); g_free(urltarget); }
static gboolean cw_applet_fill (MatePanelApplet *applet, const gchar *iid, gpointer data) { WinPickerApp *app; GtkWidget *eb, *tasks, *title; gchar *ui_path; GtkActionGroup *action_group; GObjectClass *object_class; if (strcmp (iid, "MateWindowPicker") != 0) return FALSE; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* Have our background automatically painted. */ mate_panel_applet_set_background_widget (MATE_PANEL_APPLET (applet), GTK_WIDGET (applet)); wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER); app = g_slice_new0 (WinPickerApp); mainapp = app; object_class = G_OBJECT_GET_CLASS (G_OBJECT(applet)); object_class->finalize = cw_applet_finalize; parent_class = g_type_class_peek_parent (object_class); /* gsettings prefs */ app->settings = mate_panel_applet_settings_new (applet, APPLET_SCHEMA); g_signal_connect (app->settings, "changed::" SHOW_WIN_KEY, G_CALLBACK (on_show_all_windows_changed), app); g_signal_connect (app->settings, "changed::" SHOW_HOME_TITLE_KEY, G_CALLBACK (on_show_home_title_changed), app); g_signal_connect (app->settings, "changed::" BOLD_WINDOW_TITLE_KEY, G_CALLBACK (on_bold_window_title_changed), app); app->applet = GTK_WIDGET (applet); force_no_focus_padding (GTK_WIDGET (applet)); gtk_container_set_border_width (GTK_CONTAINER (applet), 0); eb = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (applet), eb); gtk_container_set_border_width (GTK_CONTAINER (eb), 0); tasks = app->tasks = task_list_get_default (); gtk_box_pack_start (GTK_BOX (eb), tasks, FALSE, FALSE, 0); title = app->title = task_title_new (); gtk_box_pack_start (GTK_BOX (eb), title, TRUE, TRUE, 0); gtk_widget_show_all (GTK_WIDGET (applet)); on_show_all_windows_changed (app->settings, SHOW_WIN_KEY, app); on_show_home_title_changed (app->settings, SHOW_HOME_TITLE_KEY, app); on_bold_window_title_changed (app->settings, BOLD_WINDOW_TITLE_KEY, app); action_group = gtk_action_group_new ("MateWindowPicker Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (action_group, window_picker_menu_actions, G_N_ELEMENTS (window_picker_menu_actions), app); ui_path = g_build_filename (MATEWINDOWPICKER_MENU_UI_DIR, "mate-window-picker-applet-menu.xml", NULL); mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (app->applet), ui_path, action_group); g_free (ui_path); g_object_unref (action_group); mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MAJOR | MATE_PANEL_APPLET_EXPAND_MINOR | MATE_PANEL_APPLET_HAS_HANDLE); return TRUE; }
/* returns the intersection of two lists */ static GList * codec_cap_list_intersect (GList *list1, GList *list2) { GList *walk1, *walk2; CodecCap *codec_cap1, *codec_cap2; GstCaps *caps1, *caps2; GstCaps *rtp_caps1, *rtp_caps2; GList *intersection_list = NULL; for (walk1 = g_list_first (list1); walk1; walk1 = g_list_next (walk1)) { CodecCap *item = NULL; codec_cap1 = (CodecCap *)(walk1->data); caps1 = codec_cap1->caps; rtp_caps1 = codec_cap1->rtp_caps; for (walk2 = list2; walk2; walk2 = g_list_next (walk2)) { GstCaps *intersection = NULL; GstCaps *rtp_intersection = NULL; codec_cap2 = (CodecCap *)(walk2->data); caps2 = codec_cap2->caps; rtp_caps2 = codec_cap2->rtp_caps; //g_debug ("intersecting %s AND %s", gst_caps_to_string (caps1), gst_caps_to_string (caps2)); intersection = gst_caps_intersect (caps1, caps2); if (rtp_caps1 && rtp_caps2) { //g_debug ("RTP intersecting %s AND %s", gst_caps_to_string (rtp_caps1), gst_caps_to_string (rtp_caps2)); rtp_intersection = gst_caps_intersect (rtp_caps1, rtp_caps2); } if (!gst_caps_is_empty (intersection) && (rtp_intersection == NULL || !gst_caps_is_empty (rtp_intersection))) { if (item) { GList *tmplist; item->caps = gst_caps_merge (item->caps, intersection); for (tmplist = g_list_first (codec_cap2->element_list1->data); tmplist; tmplist = g_list_next (tmplist)) { if (g_list_index (item->element_list2->data, tmplist->data) < 0) { item->element_list2->data = g_list_concat ( item->element_list2->data, g_list_copy (codec_cap2->element_list1->data)); g_list_foreach (codec_cap2->element_list1->data, (GFunc) gst_object_ref, NULL); } } } else { item = g_slice_new0 (CodecCap); item->caps = intersection; if (rtp_caps1 && rtp_caps2) { item->rtp_caps = rtp_intersection; } else if (rtp_caps1) { item->rtp_caps = rtp_caps1; gst_caps_ref (rtp_caps1); } else if (rtp_caps2) { item->rtp_caps = rtp_caps2; gst_caps_ref (rtp_caps2); } /* during an intersect, we concat/copy previous lists together and put them * into 1 and 2 */ item->element_list1 = g_list_concat ( copy_element_list (codec_cap1->element_list1), copy_element_list (codec_cap1->element_list2)); item->element_list2 = g_list_concat ( copy_element_list (codec_cap2->element_list1), copy_element_list (codec_cap2->element_list2)); intersection_list = g_list_append (intersection_list, item); if (rtp_intersection) { break; } } } else { if (rtp_intersection) gst_caps_unref (rtp_intersection); gst_caps_unref (intersection); } } } return intersection_list; }