GQuark _EscalateSubprocessErrorQuark() { return g_quark_from_string("escalate-subprocess-error-quark"); }
/*************************** * * * Encodings dialog window * * * **************************/ void gxi_edit_encodings_clicked_cb (GtkButton *button, GncXmlImportData *data) { GtkBuilder *builder; GtkWidget *dialog; GtkListStore *list_store; GtkTreeStore *tree_store; GtkTreeIter iter, parent, *parent_ptr; GList *encodings_bak, *enc_iter; const gchar *encoding; system_encoding_type *system_enc; gpointer enc_ptr; gint i, j; builder = gtk_builder_new(); gnc_builder_add_from_file (builder, "assistant-xml-encoding.glade", "Encodings Dialog"); dialog = GTK_WIDGET(gtk_builder_get_object (builder, "Encodings Dialog")); data->encodings_dialog = dialog; gtk_builder_connect_signals_full (builder, gnc_builder_connect_full_func, data); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->assistant)); data->available_encs_view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "available_encs_view")); data->custom_enc_entry = GTK_WIDGET(gtk_builder_get_object (builder, "custom_enc_entry")); /* set up selected encodings list */ data->selected_encs_view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "selected_encs_view")); list_store = gtk_list_store_new (ENC_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER); for (enc_iter = data->encodings; enc_iter; enc_iter = enc_iter->next) { encoding = g_quark_to_string (GPOINTER_TO_UINT (enc_iter->data)); gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, ENC_COL_STRING, encoding, ENC_COL_QUARK, enc_iter->data, -1); } gtk_tree_view_insert_column_with_attributes ( data->selected_encs_view, -1, NULL, gtk_cell_renderer_text_new (), "text", ENC_COL_STRING, NULL); gtk_tree_view_set_model (data->selected_encs_view, GTK_TREE_MODEL (list_store)); g_object_unref (list_store); /* set up system encodings list */ data->available_encs_view = GTK_TREE_VIEW (gtk_builder_get_object (builder, "available_encs_view")); tree_store = gtk_tree_store_new (ENC_NUM_COLS, G_TYPE_STRING, G_TYPE_POINTER); for (i = 0, system_enc = system_encodings; i < n_system_encodings; i++, system_enc++) { if (i == 0) { /* first system encoding */ parent_ptr = NULL; } else { parent_ptr = &iter; for (j = 0; j < system_enc->parent; j++) if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (tree_store), &parent, &iter)) { /* go up one level */ iter = parent; } else { /* no parent to toplevel element */ parent_ptr = NULL; } } if (system_enc->encoding) enc_ptr = GUINT_TO_POINTER (g_quark_from_string (system_enc->encoding)); else enc_ptr = NULL; gtk_tree_store_append (tree_store, &iter, parent_ptr); gtk_tree_store_set (tree_store, &iter, ENC_COL_STRING, gettext (system_enc->text), ENC_COL_QUARK, enc_ptr, -1); } gtk_tree_view_insert_column_with_attributes ( data->available_encs_view, -1, NULL, gtk_cell_renderer_text_new (), "text", ENC_COL_STRING, NULL); gtk_tree_view_set_model (data->available_encs_view, GTK_TREE_MODEL (tree_store)); g_object_unref (tree_store); /* run the dialog */ encodings_bak = g_list_copy (data->encodings); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) { g_list_free (encodings_bak); if (!g_list_find (data->encodings, GUINT_TO_POINTER (data->default_encoding))) { /* choose top level encoding then */ data->default_encoding = GPOINTER_TO_UINT (data->encodings->data); } /* update whole page */ gxi_check_file (data); gxi_update_default_enc_combo (data); gxi_update_string_box (data); gxi_update_conversion_forward (data); } else { g_list_free (data->encodings); data->encodings = encodings_bak; } g_object_unref(G_OBJECT(builder)); gtk_widget_destroy (dialog); data->encodings_dialog = NULL; }
static gboolean gwy_si_unit_parse(GwySIUnit *siunit, const gchar *string) { GwySimpleUnit unit; gdouble q; const gchar *end; gchar *p, *e; gint n, i, pfpower; GString *buf; gboolean dividing = FALSE; g_array_set_size(siunit->units, 0); siunit->power10 = 0; if (!string || !*string) return TRUE; /* give up when it looks too wild */ end = strpbrk(string, "\177\001\002\003\004\005\006\007" "\010\011\012\013\014\015\016\017" "\020\021\022\023\024\025\026\027" "\030\031\032\033\034\035\036\037" "!#$&()*,:;=?@\\[]_`|{}"); if (end) { g_warning("Invalid character 0x%02x", *end); return FALSE; } /* may start with a multiplier, but it must be a power of 10 */ q = g_ascii_strtod(string, (gchar**)&end); if (end != string) { string = end; siunit->power10 = ROUND(log10(q)); if (q <= 0 || fabs(log(q/pow10(siunit->power10))) > 1e-14) { g_warning("Bad multiplier %g", q); siunit->power10 = 0; } else if (g_str_has_prefix(string, "<sup>")) { string += strlen("<sup>"); n = strtol(string, (gchar**)&end, 10); if (end == string) g_warning("Bad exponent %s", string); else if (!g_str_has_prefix(end, "</sup>")) g_warning("Expected </sup> after exponent"); else siunit->power10 *= n; string = end; } else if (string[0] == '^') { string++; n = strtol(string, (gchar**)&end, 10); if (end == string) g_warning("Bad exponent %s", string); else siunit->power10 *= n; string = end; } } while (g_ascii_isspace(*string)) string++; buf = g_string_new(""); /* the rest are units */ while (*string) { /* units are separated with whitespace and maybe a division sign */ end = string; do { end = strpbrk(end, " /"); if (!end || end == string || *end != '/' || *(end-1) != '<') break; end++; } while (TRUE); if (!end) end = string + strlen(string); g_string_set_size(buf, 0); g_string_append_len(buf, string, end - string); /* fix sloppy notations */ if (buf->str[0] == '\272') { if (!buf->str[1]) g_string_assign(buf, "deg"); else { g_string_erase(buf, 0, 1); g_string_prepend(buf, "°"); } } else if (gwy_strequal(buf->str, "°")) g_string_assign(buf, "deg"); else if (buf->str[0] == '\305' && !buf->str[1]) g_string_assign(buf, "Å"); else if (gwy_strequal(buf->str, "Å")) g_string_assign(buf, "Å"); else if (gwy_strequal(buf->str, "AA")) g_string_assign(buf, "Å"); /* get prefix, but be careful not to split mol to mili-ol */ pfpower = 0; for (i = 0; i < G_N_ELEMENTS(known_units); i++) { if (g_str_has_prefix(buf->str, known_units[i]) && !g_ascii_isalpha(buf->str[strlen(known_units[i])])) break; } if (i == G_N_ELEMENTS(known_units) && strlen(buf->str) > 1) { for (i = 0; i < G_N_ELEMENTS(SI_prefixes); i++) { const gchar *pfx = SI_prefixes[i].prefix; if (g_str_has_prefix(buf->str, pfx) && g_ascii_isalpha(buf->str[strlen(pfx)])) { pfpower = SI_prefixes[i].power10; g_string_erase(buf, 0, strlen(pfx)); break; } } } /* get unit power */ unit.power = 1; if ((p = strstr(buf->str + 1, "<sup>"))) { unit.power = strtol(p + strlen("<sup>"), &e, 10); if (e == p + strlen("<sup>") || !g_str_has_prefix(e, "</sup>")) { g_warning("Bad power %s", p); unit.power = 1; } else if (!unit.power || abs(unit.power) > 12) { g_warning("Bad power %d", unit.power); unit.power = 1; } g_string_truncate(buf, p - buf->str); } else if ((p = strchr(buf->str + 1, '^'))) { unit.power = strtol(p + 1, &e, 10); if (e == p + 1 || *e) { g_warning("Bad power %s", p); unit.power = 1; } else if (!unit.power || abs(unit.power) > 12) { g_warning("Bad power %d", unit.power); unit.power = 1; } g_string_truncate(buf, p - buf->str); } else if (buf->len) { /* Are we really desperate? Yes, we are! */ i = buf->len; while (i && (g_ascii_isdigit(buf->str[i-1]) || buf->str[i-1] == '-')) i--; if (i != buf->len) { unit.power = strtol(buf->str + i, NULL, 10); if (!unit.power || abs(unit.power) > 12) { g_warning("Bad power %d", unit.power); unit.power = 1; } g_string_truncate(buf, i); } } /* handle some ugly, but quite common units */ if (gwy_strequal(buf->str, "Å")) { pfpower -= 10; g_string_assign(buf, "m"); } else if (gwy_strequal(buf->str, "%")) { pfpower -= 2; g_string_assign(buf, ""); } /* elementary sanity */ if (!g_utf8_validate(buf->str, -1, (const gchar**)&p)) { g_warning("Unit string is not valid UTF-8"); g_string_truncate(buf, p - buf->str); } if (!buf->len) { /* maybe it's just percentage. cross fingers and proceed. */ if (dividing) unit.power = -unit.power; siunit->power10 += unit.power * pfpower; } else if (!g_ascii_isalpha(buf->str[0]) && (guchar)buf->str[0] < 128) g_warning("Invalid base unit: %s", buf->str); else { /* append it */ unit.unit = g_quark_from_string(buf->str); if (dividing) unit.power = -unit.power; gwy_debug("<%s:%u> %d\n", buf->str, unit.unit, unit.power); siunit->power10 += unit.power * pfpower; g_array_append_val(siunit->units, unit); } /* TODO: scan known obscure units */ unit.traits = 0; /* get to the next token, looking for division */ while (g_ascii_isspace(*end)) end++; if (*end == '/') { if (dividing) g_warning("Cannot group multiple divisions"); dividing = TRUE; end++; while (g_ascii_isspace(*end)) end++; } string = end; } gwy_si_unit_canonicalize(siunit); return TRUE; }
static guint dawati_rc_style_parse (GtkRcStyle *rc_style, GtkSettings *settings, GScanner *scanner) { GTokenType token; static GQuark scope_id; guint old_scope; int i; DawatiRcStyle *mb_style = DAWATI_RC_STYLE (rc_style); if (!scope_id) scope_id = g_quark_from_string ("dawati-gtk-engine"); /* set the new scope and store the old scope id */ old_scope = g_scanner_set_scope (scanner, scope_id); /* register the symbols if we haven't already done so */ if (!g_scanner_lookup_symbol (scanner, dawati_rc_symbols[0].name)) { for (i = 0; dawati_rc_symbols[i].name; i++) { g_scanner_scope_add_symbol (scanner, scope_id, dawati_rc_symbols[i].name, GINT_TO_POINTER (dawati_rc_symbols[i]. token)); } } token = g_scanner_peek_next_token (scanner); while (token != G_TOKEN_RIGHT_CURLY) { switch (token) { case TOKEN_BORDER_COLOR: token = dawati_parse_border_color (scanner, mb_style); break; case TOKEN_RADIUS: g_scanner_get_next_token (scanner); token = dawati_get_token (scanner, G_TOKEN_EQUAL_SIGN); if (token != G_TOKEN_NONE) break; token = dawati_get_token (scanner, G_TOKEN_INT); if (token != G_TOKEN_NONE) break; mb_style->radius = scanner->value.v_int; break; case TOKEN_SHADOW: g_scanner_get_next_token (scanner); token = dawati_get_token (scanner, G_TOKEN_EQUAL_SIGN); if (token != G_TOKEN_NONE) break; token = dawati_get_token (scanner, G_TOKEN_FLOAT); if (token != G_TOKEN_NONE) break; mb_style->shadow = scanner->value.v_float; mb_style->shadow_set = TRUE; break; default: g_scanner_get_next_token (scanner); token = G_TOKEN_RIGHT_CURLY; break; } if (token != G_TOKEN_NONE) { return token; } token = g_scanner_peek_next_token (scanner); } g_scanner_get_next_token (scanner); g_scanner_set_scope (scanner, old_scope); return G_TOKEN_NONE; }
OlAppInfo * ol_app_info_new (const char *cmdline, const char *name, const char *icon_name, enum OlAppInfoFlags flags, GError **error) { if (cmdline == NULL) { if (error) *error = g_error_new (g_quark_from_string ("OSD Lyrics"), 0, "cmdline cannot be NULL"); return NULL; } int cmd_index = 0; if (flags & OL_APP_INFO_SECOND_IS_EXEC) cmd_index = 1; gchar **argv = NULL; gint argc = 0; GError *parse_error = NULL; if (!g_shell_parse_argv (cmdline, &argc, &argv, &parse_error)) { if (error) *error = g_error_new (g_quark_from_string ("OSD Lyrics"), 0, "Cannot parse cmdline: %s", parse_error->message); g_error_free (parse_error); return NULL; } if (argc <= cmd_index) { if (error) *error = g_error_new (g_quark_from_string ("OSD Lyrics"), 0, "Command name is required in cmdline"); g_strfreev (argv); return NULL; } OlAppInfo *info = g_object_new (OL_TYPE_APP_INFO, NULL); info->binfile = _find_binfile (argv[cmd_index], (flags & OL_APP_INFO_WITH_PREFIX) != 0); if (info->binfile == NULL) { info->binfile = g_strdup (argv[cmd_index]); info->cmdline = g_strdup (cmdline); info->should_show = FALSE; } else { info->should_show = TRUE; _strv_replace (argv, cmd_index, info->binfile); info->cmdline = _str_join_argv (argv); } if (!name) name = info->binfile; if (!icon_name) icon_name = info->binfile; info->icon = _icon_new_from_name (icon_name); info->name = g_strdup (name); if (flags & OL_APP_INFO_PREFER_DESKTOP_FILE) _app_info_set_from_desktop_file (info, flags); return info; }
static GObject* hippo_image_cache_parse(HippoObjectCache *cache, const char *url, const char *content_type, GString *content, GError **error_p) { cairo_surface_t *csurface; HippoSurface *surface; g_debug("image cache parse '%s'", url); if (has_prefix(content, PNG_MAGIC_PREFIX)) { GStringReader reader; reader.str = content; reader.already_read = 0; csurface = cairo_image_surface_create_from_png_stream(gstring_read_func, &reader); if (csurface != NULL && cairo_surface_status(csurface) == CAIRO_STATUS_SUCCESS) { surface = hippo_surface_new(csurface); cairo_surface_destroy(csurface); } else { const char *msg; if (csurface) { msg = cairo_status_to_string(cairo_surface_status(csurface)); cairo_surface_destroy(csurface); } else { msg = _("Corrupt image"); } surface = NULL; g_set_error(error_p, g_quark_from_string("cairo-surface-error"), 0, msg); goto failed; } } else if (has_prefix(content, JPEG_MAGIC_PREFIX)) { csurface = hippo_parse_jpeg(content->str, content->len, error_p); if (csurface == NULL) { g_debug("JPEG parse failed for '%s'", url); goto failed; } surface = hippo_surface_new(csurface); cairo_surface_destroy(csurface); } else { g_debug("Unknown image format for '%s'", url); g_set_error(error_p, HIPPO_ERROR, HIPPO_ERROR_FAILED, _("Unknown image format")); goto failed; } return G_OBJECT(surface); failed: g_debug("Image parse failed for '%s'", url); g_assert(error_p == NULL || *error_p != NULL); return NULL; }
RygelHTTPItemURI* rygel_http_item_uri_construct_from_string (GType object_type, const char* uri, RygelHTTPServer* http_server, GError** error) { #line 233 "rygel-http-item-uri.c" GError * _inner_error_; RygelHTTPItemURI * self; char* _tmp0_; RygelHTTPServer* _tmp1_; char* request_uri; char** _tmp3_; gint _parts_size_; gint parts_length1; char** _tmp2_; char** parts; gboolean _tmp4_ = FALSE; #line 45 "rygel-http-item-uri.vala" g_return_val_if_fail (uri != NULL, NULL); #line 45 "rygel-http-item-uri.vala" g_return_val_if_fail (http_server != NULL, NULL); #line 249 "rygel-http-item-uri.c" _inner_error_ = NULL; #line 45 "rygel-http-item-uri.vala" self = (RygelHTTPItemURI*) g_object_new (object_type, NULL); #line 49 "rygel-http-item-uri.vala" self->thumbnail_index = -1; #line 50 "rygel-http-item-uri.vala" self->subtitle_index = -1; #line 51 "rygel-http-item-uri.vala" self->transcode_target = (_tmp0_ = NULL, _g_free0 (self->transcode_target), _tmp0_); #line 52 "rygel-http-item-uri.vala" self->http_server = (_tmp1_ = _g_object_ref0 (http_server), _g_object_unref0 (self->http_server), _tmp1_); #line 54 "rygel-http-item-uri.vala" request_uri = string_replace (uri, rygel_http_server_get_path_root (http_server), ""); #line 263 "rygel-http-item-uri.c" parts = (_tmp3_ = _tmp2_ = g_strsplit (request_uri, "/", 0), parts_length1 = _vala_array_length (_tmp2_), _parts_size_ = parts_length1, _tmp3_); #line 57 "rygel-http-item-uri.vala" if (parts_length1 < 2) { #line 57 "rygel-http-item-uri.vala" _tmp4_ = TRUE; #line 269 "rygel-http-item-uri.c" } else { #line 57 "rygel-http-item-uri.vala" _tmp4_ = (parts_length1 % 2) == 0; #line 273 "rygel-http-item-uri.c" } #line 57 "rygel-http-item-uri.vala" if (_tmp4_) { #line 277 "rygel-http-item-uri.c" _inner_error_ = g_error_new (RYGEL_HTTP_REQUEST_ERROR, RYGEL_HTTP_REQUEST_ERROR_BAD_REQUEST, _ ("Invalid URI '%s'"), request_uri); { if (_inner_error_->domain == RYGEL_HTTP_REQUEST_ERROR) { g_propagate_error (error, _inner_error_); _g_free0 (request_uri); parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL); g_object_unref (self); return NULL; } else { _g_free0 (request_uri); parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } } { gint i; #line 62 "rygel-http-item-uri.vala" i = 1; #line 299 "rygel-http-item-uri.c" { gboolean _tmp5_; #line 62 "rygel-http-item-uri.vala" _tmp5_ = TRUE; #line 62 "rygel-http-item-uri.vala" while (TRUE) { #line 306 "rygel-http-item-uri.c" GQuark _tmp13_; const char* _tmp12_; static GQuark _tmp13__label0 = 0; static GQuark _tmp13__label1 = 0; static GQuark _tmp13__label2 = 0; static GQuark _tmp13__label3 = 0; #line 62 "rygel-http-item-uri.vala" if (!_tmp5_) { #line 62 "rygel-http-item-uri.vala" i = i + 2; #line 317 "rygel-http-item-uri.c" } #line 62 "rygel-http-item-uri.vala" _tmp5_ = FALSE; #line 62 "rygel-http-item-uri.vala" if (!(i < (parts_length1 - 1))) { #line 62 "rygel-http-item-uri.vala" break; #line 325 "rygel-http-item-uri.c" } _tmp12_ = parts[i]; _tmp13_ = (NULL == _tmp12_) ? 0 : g_quark_from_string (_tmp12_); if (_tmp13_ == ((0 != _tmp13__label0) ? _tmp13__label0 : (_tmp13__label0 = g_quark_from_static_string ("item")))) switch (0) { default: { guchar* _tmp9_; gint _data_size_; gint data_length1; size_t _tmp7_; char* _tmp6_; guchar* _tmp8_; guchar* data; GString* builder; char* _tmp10_; data = (_tmp9_ = (_tmp8_ = g_base64_decode (_tmp6_ = soup_uri_decode (parts[i + 1]), &_tmp7_), _g_free0 (_tmp6_), _tmp8_), data_length1 = _tmp7_, _data_size_ = data_length1, _tmp9_); #line 66 "rygel-http-item-uri.vala" builder = g_string_new (""); #line 67 "rygel-http-item-uri.vala" g_string_append (builder, (const char*) data); #line 68 "rygel-http-item-uri.vala" self->item_id = (_tmp10_ = g_strdup (builder->str), _g_free0 (self->item_id), _tmp10_); #line 349 "rygel-http-item-uri.c" data = (g_free (data), NULL); _g_string_free0 (builder); #line 70 "rygel-http-item-uri.vala" break; #line 354 "rygel-http-item-uri.c" } } else if (_tmp13_ == ((0 != _tmp13__label1) ? _tmp13__label1 : (_tmp13__label1 = g_quark_from_static_string ("transcoded")))) switch (0) { default: { char* _tmp11_; #line 72 "rygel-http-item-uri.vala" self->transcode_target = (_tmp11_ = soup_uri_decode (parts[i + 1]), _g_free0 (self->transcode_target), _tmp11_); #line 74 "rygel-http-item-uri.vala" break; #line 365 "rygel-http-item-uri.c" } } else if (_tmp13_ == ((0 != _tmp13__label2) ? _tmp13__label2 : (_tmp13__label2 = g_quark_from_static_string ("thumbnail")))) switch (0) { default: { #line 76 "rygel-http-item-uri.vala" self->thumbnail_index = atoi (parts[i + 1]); #line 78 "rygel-http-item-uri.vala" break; #line 375 "rygel-http-item-uri.c" } } else if (_tmp13_ == ((0 != _tmp13__label3) ? _tmp13__label3 : (_tmp13__label3 = g_quark_from_static_string ("subtitle")))) switch (0) { default: { #line 80 "rygel-http-item-uri.vala" self->subtitle_index = atoi (parts[i + 1]); #line 82 "rygel-http-item-uri.vala" break; #line 385 "rygel-http-item-uri.c" } } else switch (0) { default: { #line 84 "rygel-http-item-uri.vala" break; #line 393 "rygel-http-item-uri.c" } } } } } #line 88 "rygel-http-item-uri.vala" if (self->item_id == NULL) { #line 401 "rygel-http-item-uri.c" _inner_error_ = g_error_new_literal (RYGEL_HTTP_REQUEST_ERROR, RYGEL_HTTP_REQUEST_ERROR_NOT_FOUND, _ ("Not Found")); { if (_inner_error_->domain == RYGEL_HTTP_REQUEST_ERROR) { g_propagate_error (error, _inner_error_); _g_free0 (request_uri); parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL); g_object_unref (self); return NULL; } else { _g_free0 (request_uri); parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return NULL; } } } _g_free0 (request_uri); parts = (_vala_array_free (parts, parts_length1, (GDestroyNotify) g_free), NULL); return self; }
/* A window was closed */ static void _xfdashboard_application_tracker_on_window_closed(XfdashboardApplicationTracker *self, XfdashboardWindowTrackerWindow *inWindow, gpointer inUserData) { XfdashboardApplicationTrackerPrivate *priv; XfdashboardApplicationTrackerItem *item; g_return_if_fail(XFDASHBOARD_IS_APPLICATION_TRACKER(self)); g_return_if_fail(XFDASHBOARD_IS_WINDOW_TRACKER_WINDOW(inWindow)); priv=self->priv; /* Find application tracker item in list of known running applications * matching the window just closed. */ item= _xfdashboard_application_tracker_find_item_by_window(self, inWindow); if(!item) { g_debug("Could not find running application for window '%s'", xfdashboard_window_tracker_window_get_title(inWindow)); return; } g_debug("Closing window '%s' for desktop ID '%s'", xfdashboard_window_tracker_window_get_title(inWindow), item->desktopID); /* Remove window from found application tracker item */ _xfdashboard_application_tracker_item_remove_window(item, inWindow); /* If it was the last window then application is not running anymore * because it has no window. */ if(!item->windows || g_list_length(item->windows)==0) { gchar *desktopID; g_debug("Closing window '%s' for desktop ID '%s' closed last window so remove application from list of running ones", xfdashboard_window_tracker_window_get_title(inWindow), item->desktopID); /* Create a copy of desktop ID for signal emission because the * application tracker item will be removed and freed before. */ desktopID=g_strdup(item->desktopID); /* Remove application tracker item from list of running applications * and free it. */ priv->runningApps=g_list_remove(priv->runningApps, item); _xfdashboard_application_tracker_item_free(item); /* Emit signal as this application is not running anymore */ g_debug("Emitting signal 'state-changed' to stopped for desktop ID '%s'", desktopID); g_signal_emit(self, XfdashboardApplicationTrackerSignals[SIGNAL_STATE_CHANGED], g_quark_from_string(desktopID), desktopID, FALSE); /* Release allocated resources */ g_free(desktopID); } }
static int mfw_gst_vpuenc_init_encoder(GstPad *pad, enum v4l2_memory memory) { GstVPU_Enc *vpu_enc = MFW_GST_VPU_ENC(GST_PAD_PARENT(pad)); gchar *mime = "undef"; gint ret; GstCaps *caps = NULL; struct v4l2_format fmt; int retval, i; if (!vpu_enc->codecTypeProvided) { GST_ERROR("Incomplete command line.\n"); GError *error = NULL; GQuark domain = g_quark_from_string("mfw_vpuencoder"); error = g_error_new(domain, 10, "fatal error"); gst_element_post_message(GST_ELEMENT(vpu_enc), gst_message_new_error (GST_OBJECT(vpu_enc), error, "Incomplete command line - codec type was not provided.")); return GST_FLOW_ERROR; } fmt.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; fmt.fmt.pix.width = vpu_enc->width; fmt.fmt.pix.height = vpu_enc->height; fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YVU420; retval = ioctl(vpu_enc->vpu_fd, VIDIOC_S_FMT, &fmt); if (retval) { printf("VIDIOC_S_FMT failed: %s\n", strerror(errno)); return GST_FLOW_ERROR; } reqs.memory = memory; retval = ioctl(vpu_enc->vpu_fd, VIDIOC_REQBUFS, &reqs); if (retval) { perror("VIDIOC_REQBUFS"); return GST_FLOW_ERROR; } retval = ioctl(vpu_enc->vpu_fd, VPU_IOC_CODEC, vpu_enc->codec); if (retval) { perror("VPU_IOC_CODEC"); return GST_FLOW_ERROR; } retval = ioctl(vpu_enc->vpu_fd, VPU_IOC_MJPEG_QUALITY, vpu_enc->mjpeg_quality); if (retval) { perror("VPU_IOC_MJPEG_QUALITY"); return GST_FLOW_ERROR; } for (i = 0; i < NUM_BUFFERS; i++) { struct v4l2_buffer *buf = &vpu_enc->buf_v4l2[i]; buf->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; buf->memory = memory; buf->index = i; if (memory == V4L2_MEMORY_MMAP) { retval = ioctl(vpu_enc->vpu_fd, VIDIOC_QUERYBUF, buf); if (retval) { GST_ERROR("VIDIOC_QUERYBUF failed: %s\n", strerror(errno)); return GST_FLOW_ERROR; } vpu_enc->buf_size[i] = buf->length; vpu_enc->buf_data[i] = mmap(NULL, buf->length, PROT_READ | PROT_WRITE, MAP_SHARED, vpu_enc->vpu_fd, vpu_enc->buf_v4l2[i].m.offset); } } switch (vpu_enc->codec) { case STD_MPEG4: mime = "video/mpeg"; break; case STD_AVC: mime = "video/x-h264"; break; case STD_H263: mime = "video/x-h263"; break; case STD_MJPG: mime = "image/jpeg"; break; default: return GST_FLOW_ERROR; } caps = gst_caps_new_simple(mime, "mpegversion", G_TYPE_INT, 4, "systemstream", G_TYPE_BOOLEAN, FALSE, "height", G_TYPE_INT, vpu_enc->height, "width", G_TYPE_INT, vpu_enc->width, "framerate", GST_TYPE_FRACTION, (gint32) (vpu_enc->framerate * 1000), 1000, NULL); gst_pad_set_caps(vpu_enc->srcpad, caps); vpu_enc->init = TRUE; return GST_FLOW_OK; }
/* if simulate==TRUE, return whether accel_path can be changed to * accel_key && accel_mods. otherwise, return whether accel_path * was actually changed. */ static gboolean internal_change_entry (const gchar *accel_path, guint accel_key, GdkModifierType accel_mods, gboolean replace, gboolean simulate) { GSList *node, *slist, *win_list, *group_list, *replace_list = NULL; GHashTable *group_hm, *window_hm; gboolean change_accel, removable, can_change = TRUE, seen_accel = FALSE; GQuark entry_quark; AccelEntry *entry = accel_path_lookup (accel_path); /* not much todo if there's no entry yet */ if (!entry) { if (!simulate) { gtk_accel_map_add_entry (accel_path, 0, 0); entry = accel_path_lookup (accel_path); entry->accel_key = accel_key; entry->accel_mods = accel_mods; entry->changed = TRUE; do_accel_map_changed (entry); } return TRUE; } /* if there's nothing to change, not much todo either */ if (entry->accel_key == accel_key && entry->accel_mods == accel_mods) { if (!simulate) entry->changed = TRUE; return simulate ? TRUE : FALSE; } /* The no-change case has already been handled, so * simulate doesn't make a difference here. */ if (entry->lock_count > 0) return FALSE; /* nobody's interested, easy going */ if (!entry->groups) { if (!simulate) { entry->accel_key = accel_key; entry->accel_mods = accel_mods; entry->changed = TRUE; do_accel_map_changed (entry); } return TRUE; } /* 1) fetch all accel groups affected by this entry */ entry_quark = g_quark_try_string (entry->accel_path); group_hm = g_hash_table_new (NULL, NULL); window_hm = g_hash_table_new (NULL, NULL); for (slist = entry->groups; slist; slist = slist->next) g_hash_table_insert (group_hm, slist->data, slist->data); /* 2) collect acceleratables affected */ group_list = g_hash_table_slist_values (group_hm); for (slist = group_list; slist; slist = slist->next) { GtkAccelGroup *group = slist->data; for (node = _gtk_accel_group_get_accelerables (group); node; node = node->next) g_hash_table_insert (window_hm, node->data, node->data); } g_slist_free (group_list); /* 3) include all accel groups used by acceleratables */ win_list = g_hash_table_slist_values (window_hm); g_hash_table_destroy (window_hm); for (slist = win_list; slist; slist = slist->next) for (node = gtk_accel_groups_from_object (slist->data); node; node = node->next) g_hash_table_insert (group_hm, node->data, node->data); group_list = g_hash_table_slist_values (group_hm); g_hash_table_destroy (group_hm); /* 4) walk the acceleratables and figure whether they occupy accel_key&accel_mods */ if (accel_key) for (slist = win_list; slist; slist = slist->next) if (GTK_IS_WINDOW (slist->data)) /* bad kludge in lack of a GtkAcceleratable */ if (_gtk_window_query_nonaccels (slist->data, accel_key, accel_mods)) { seen_accel = TRUE; break; } removable = !seen_accel; /* 5) walk all accel groups and search for locks */ if (removable) for (slist = group_list; slist; slist = slist->next) { GtkAccelGroup *group = slist->data; GtkAccelGroupEntry *ag_entry; guint i, n; n = 0; ag_entry = entry->accel_key ? gtk_accel_group_query (group, entry->accel_key, entry->accel_mods, &n) : NULL; for (i = 0; i < n; i++) if (ag_entry[i].accel_path_quark == entry_quark) { can_change = !(ag_entry[i].key.accel_flags & GTK_ACCEL_LOCKED); if (!can_change) goto break_loop_step5; } n = 0; ag_entry = accel_key ? gtk_accel_group_query (group, accel_key, accel_mods, &n) : NULL; for (i = 0; i < n; i++) { seen_accel = TRUE; removable = !gtk_accel_group_get_is_locked (group) && !(ag_entry[i].key.accel_flags & GTK_ACCEL_LOCKED); if (!removable) goto break_loop_step5; if (ag_entry[i].accel_path_quark) replace_list = g_slist_prepend (replace_list, GUINT_TO_POINTER (ag_entry[i].accel_path_quark)); } } break_loop_step5: /* 6) check whether we can remove existing accelerators */ if (removable && can_change) for (slist = replace_list; slist; slist = slist->next) if (!internal_change_entry (g_quark_to_string (GPOINTER_TO_UINT (slist->data)), 0, 0, FALSE, TRUE)) { removable = FALSE; break; } /* 7) check conditions and proceed if possible */ change_accel = can_change && (!seen_accel || (removable && replace)); if (change_accel && !simulate) { /* ref accel groups */ for (slist = group_list; slist; slist = slist->next) g_object_ref (slist->data); /* 8) remove existing accelerators */ for (slist = replace_list; slist; slist = slist->next) internal_change_entry (g_quark_to_string (GPOINTER_TO_UINT (slist->data)), 0, 0, FALSE, FALSE); /* 9) install new accelerator */ entry->accel_key = accel_key; entry->accel_mods = accel_mods; entry->changed = TRUE; for (slist = group_list; slist; slist = slist->next) _gtk_accel_group_reconnect (slist->data, g_quark_from_string (entry->accel_path)); /* unref accel groups */ for (slist = group_list; slist; slist = slist->next) g_object_unref (slist->data); do_accel_map_changed (entry); } g_slist_free (replace_list); g_slist_free (group_list); g_slist_free (win_list); return change_accel; }
JSBool gjs_define_error_class(JSContext *context, JSObject *in_object, GIEnumInfo *info, JSObject **constructor_p, JSObject **prototype_p) { const char *constructor_name; GIBoxedInfo *glib_error_info; JSObject *prototype, *parent_proto; JSObject *constructor; jsval value; Error *priv; /* See the comment in gjs_define_boxed_class() for an * explanation of how this all works; Error is pretty much the * same as Boxed (except that we inherit from GLib.Error). */ constructor_name = g_base_info_get_name( (GIBaseInfo*) info); if (gjs_object_get_property(context, in_object, constructor_name, &value)) { JSObject *constructor; if (!JSVAL_IS_OBJECT(value)) { gjs_throw(context, "Existing property '%s' does not look like a constructor", constructor_name); return JS_FALSE; } constructor = JSVAL_TO_OBJECT(value); gjs_object_get_property(context, constructor, "prototype", &value); if (!JSVAL_IS_OBJECT(value)) { gjs_throw(context, "error %s prototype property does not appear to exist or has wrong type", constructor_name); return JS_FALSE; } else { if (prototype_p) *prototype_p = JSVAL_TO_OBJECT(value); if (constructor_p) *constructor_p = constructor; return JS_TRUE; } } g_irepository_require(NULL, "GLib", "2.0", 0, NULL); glib_error_info = (GIBoxedInfo*) g_irepository_find_by_name(NULL, "GLib", "Error"); parent_proto = gjs_lookup_boxed_prototype(context, glib_error_info); g_base_info_unref((GIBaseInfo*)glib_error_info); if (!gjs_init_class_dynamic(context, in_object, parent_proto, g_base_info_get_namespace( (GIBaseInfo*) info), constructor_name, &gjs_error_class, gjs_error_constructor, 1, /* props of prototype */ &gjs_error_proto_props[0], /* funcs of prototype */ &gjs_error_proto_funcs[0], /* props of constructor, MyConstructor.myprop */ NULL, /* funcs of constructor, MyConstructor.myfunc() */ &gjs_error_constructor_funcs[0], &prototype, &constructor)) { gjs_log_exception(context, NULL); gjs_fatal("Can't init class %s", constructor_name); } GJS_INC_COUNTER(gerror); priv = g_slice_new0(Error); priv->info = info; g_base_info_ref( (GIBaseInfo*) priv->info); priv->domain = g_quark_from_string (g_enum_info_get_error_domain(priv->info)); JS_SetPrivate(context, prototype, priv); gjs_debug(GJS_DEBUG_GBOXED, "Defined class %s prototype is %p class %p in object %p", constructor_name, prototype, JS_GET_CLASS(context, prototype), in_object); gjs_define_enum_values(context, constructor, priv->info); if (constructor_p) *constructor_p = constructor; if (prototype_p) *prototype_p = prototype; return JS_TRUE; }
//! //! @brief Callback function to read data in from a file and send it to a stream //! @param data A pointer to a LwIoProcessFdData object //! @returns Returns if there was an error //! gpointer _stdin_func (gpointer data) { //Sanity checks g_return_val_if_fail (data != NULL, NULL); //Declarations const int MAX_CHUNK = 128; char buffer[MAX_CHUNK]; size_t chunk; size_t curpos; size_t end; double fraction; FILE *file; FILE *stream; LwIoProcessFdData* in; const char *message; GQuark domain; GCancellable *cancellable; gboolean is_cancelled; //Initalizations in = data; chunk = 0; curpos = 0; end = lw_io_get_filesize (in->uri); fraction = 0.0; file = fopen(in->uri, "rb"); stream = fdopen(in->fd, "ab"); cancellable = in->cancellable; while (file != NULL && ferror(file) == 0 && feof(file) == 0) { is_cancelled = (cancellable != NULL && g_cancellable_is_cancelled (cancellable)); if (is_cancelled) break; fraction = ((double) curpos / (double) end); if (in->cb != NULL) in->cb (fraction, in->data); chunk = fread(buffer, sizeof(char), MAX_CHUNK, file); curpos += chunk; chunk = fwrite(buffer, sizeof(char), chunk, stream); fflush(stream); } fraction = 1.0; if (in->cb != NULL) in->cb (fraction, in->data); if (ferror(file) != 0) { domain = g_quark_from_string (LW_IO_ERROR); message = gettext("Unable to read data from the input file."); in->error = g_error_new (domain, LW_IO_READ_ERROR, "%s", message); } else if(ferror(stream) != 0) { domain = g_quark_from_string (LW_IO_ERROR); message = gettext("Unable to write to the external program's input stream."); in->error = g_error_new (domain, LW_IO_WRITE_ERROR, "%s", message); } //Cleanup fclose(file); fclose(stream); return (in->error); }
//! //! @brief Downloads a file using libcurl //! @param source_path String of the source url //! @param target_path String of the path to save the file locally //! @param cb A LwIoProgressCallback to use to give progress feedback or NULL //! @param data gpointer to data to pass to the function pointer //! @param error Error handling //! gboolean lw_io_download (const gchar *SOURCE_PATH, const gchar *TARGET_PATH, LwIoProgressCallback cb, gpointer data, GCancellable *cancellable, GError **error) { if (error != NULL && *error != NULL) return FALSE; curl_global_init (CURL_GLOBAL_ALL); //Declarations GQuark quark; CURL *curl; CURLcode res; FILE *outfile; const gchar *message; LwIoProgressCallbackWithData cbwdata; gboolean is_cancelled; //Initializations curl = curl_easy_init (); outfile = fopen(TARGET_PATH, "wb"); cbwdata.cb = cb; cbwdata.data = data; cbwdata.cancellable = cancellable; res = 0; if (curl != NULL || outfile != NULL) { curl_easy_setopt(curl, CURLOPT_URL, SOURCE_PATH); curl_easy_setopt(curl, CURLOPT_WRITEDATA, outfile); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _libcurl_write_func); curl_easy_setopt(curl, CURLOPT_READFUNCTION, _libcurl_read_func); if (cb != NULL) { curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, _libcurl_update_progress); curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &cbwdata); } res = curl_easy_perform(curl); } fclose(outfile); curl_easy_cleanup(curl); is_cancelled = (cancellable != NULL && g_cancellable_is_cancelled (cancellable)); if (is_cancelled) return 1; if (res != 0 && is_cancelled == FALSE) { g_remove (TARGET_PATH); if (error != NULL) { message = gettext(curl_easy_strerror(res)); quark = g_quark_from_string (LW_IO_ERROR); *error = g_error_new_literal (quark, LW_IO_DOWNLOAD_ERROR, message); } } curl_global_cleanup (); return (res == 0); }
static guint clearlooks_rc_style_parse (GtkRcStyle *rc_style, GtkSettings *settings, GScanner *scanner) { static GQuark scope_id = 0; ClearlooksRcStyle *clearlooks_style = CLEARLOOKS_RC_STYLE (rc_style); guint old_scope; guint token; /* Set up a new scope in this scanner. */ if (!scope_id) scope_id = g_quark_from_string("clearlooks_theme_engine"); /* If we bail out due to errors, we *don't* reset the scope, so the * error messaging code can make sense of our tokens. */ old_scope = g_scanner_set_scope(scanner, scope_id); /* Now check if we already added our symbols to this scope * (in some previous call to clearlooks_rc_style_parse for the * same scanner. */ if (!g_scanner_lookup_symbol(scanner, clearlooks_rc_symbols)) { gchar *current_symbol = clearlooks_rc_symbols; gint i = G_TOKEN_LAST + 1; /* Add our symbols */ while ((current_symbol[0] != '\0') && (i < TOKEN_LAST)) { g_scanner_scope_add_symbol(scanner, scope_id, current_symbol, GINT_TO_POINTER (i)); current_symbol += strlen(current_symbol) + 1; i++; } g_assert (i == TOKEN_LAST && current_symbol[0] == '\0'); } /* We're ready to go, now parse the top level */ token = g_scanner_peek_next_token(scanner); while (token != G_TOKEN_RIGHT_CURLY) { switch (token) { case TOKEN_FOCUSCOLOR: token = clearlooks_gtk2_rc_parse_color (settings, scanner, rc_style, &clearlooks_style->focus_color); clearlooks_style->flags |= CL_FLAG_FOCUS_COLOR; break; case TOKEN_SCROLLBARCOLOR: token = clearlooks_gtk2_rc_parse_color (settings, scanner, rc_style, &clearlooks_style->scrollbar_color); clearlooks_style->flags |= CL_FLAG_SCROLLBAR_COLOR; break; case TOKEN_COLORIZESCROLLBAR: token = clearlooks_gtk2_rc_parse_boolean (settings, scanner, &clearlooks_style->colorize_scrollbar); clearlooks_style->flags |= CL_FLAG_COLORIZE_SCROLLBAR; break; case TOKEN_CONTRAST: token = clearlooks_gtk2_rc_parse_double (settings, scanner, &clearlooks_style->contrast); clearlooks_style->flags |= CL_FLAG_CONTRAST; break; case TOKEN_RELIEFSTYLE: token = clearlooks_gtk2_rc_parse_int (settings, scanner, &clearlooks_style->reliefstyle); clearlooks_style->flags |= CL_FLAG_RELIEFSTYLE; break; case TOKEN_MENUBARSTYLE: token = clearlooks_gtk2_rc_parse_int (settings, scanner, &clearlooks_style->menubarstyle); clearlooks_style->flags |= CL_FLAG_MENUBARSTYLE; break; case TOKEN_TOOLBARSTYLE: token = clearlooks_gtk2_rc_parse_int (settings, scanner, &clearlooks_style->toolbarstyle); clearlooks_style->flags |= CL_FLAG_TOOLBARSTYLE; break; case TOKEN_ANIMATION: token = clearlooks_gtk2_rc_parse_boolean (settings, scanner, &clearlooks_style->animation); clearlooks_style->flags |= CL_FLAG_ANIMATION; break; case TOKEN_STYLE: token = clearlooks_gtk2_rc_parse_style (settings, scanner, &clearlooks_style->style); clearlooks_style->flags |= CL_FLAG_STYLE; break; case TOKEN_RADIUS: token = clearlooks_gtk2_rc_parse_double (settings, scanner, &clearlooks_style->radius); clearlooks_style->flags |= CL_FLAG_RADIUS; break; case TOKEN_HINT: token = ge_rc_parse_hint (scanner, &clearlooks_style->hint); clearlooks_style->flags |= CL_FLAG_HINT; break; case TOKEN_DISABLE_FOCUS: token = clearlooks_gtk2_rc_parse_boolean (settings, scanner, &clearlooks_style->disable_focus); clearlooks_style->flags |= CL_FLAG_DISABLE_FOCUS; break; /* stuff to ignore */ case TOKEN_SUNKENMENU: token = clearlooks_gtk2_rc_parse_dummy (settings, scanner, "sunkenmenu"); break; case TOKEN_PROGRESSBARSTYLE: token = clearlooks_gtk2_rc_parse_dummy (settings, scanner, "progressbarstyle"); break; case TOKEN_MENUITEMSTYLE: token = clearlooks_gtk2_rc_parse_dummy (settings, scanner, "menuitemstyle"); break; case TOKEN_LISTVIEWITEMSTYLE: token = clearlooks_gtk2_rc_parse_dummy (settings, scanner, "listviewitemstyle"); break; default: g_scanner_get_next_token(scanner); token = G_TOKEN_RIGHT_CURLY; break; } if (token != G_TOKEN_NONE) return token; token = g_scanner_peek_next_token(scanner); } g_scanner_get_next_token(scanner); g_scanner_set_scope(scanner, old_scope); return G_TOKEN_NONE; }
static void accel_edited_callback (GtkCellRendererAccel *cell, gchar *path_string, guint keyval, GdkModifierType mask, guint hardware_keycode, GtkTreeView *view) { GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; KeyEntry *ke; GtkAccelGroupEntry *entries; guint n_entries; char *str; model = gtk_tree_view_get_model (view); path = gtk_tree_path_new_from_string (path_string); if (!path) return; if (!gtk_tree_model_get_iter (model, &iter, path)) { gtk_tree_path_free (path); return; } gtk_tree_path_free (path); gtk_tree_model_get (model, &iter, KEYVAL_COLUMN, &ke, -1); /* sanity check */ if (ke == NULL) return; /* Check if we already have an entry using this accel */ entries = gtk_accel_group_query (notification_group, keyval, mask, &n_entries); if (n_entries > 0) { if (entries[0].accel_path_quark != g_quark_from_string (ke->accel_path)) { GtkWidget *dialog; char *name; KeyEntry *other_key; name = gtk_accelerator_get_label (keyval, mask); other_key = entries[0].closure->data; g_assert (other_key); dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (view))), GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, _("The shortcut key “%s” is already bound to the “%s” action"), name, other_key->user_visible_name ? _(other_key->user_visible_name) : other_key->gsettings_key); g_free (name); g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_window_present (GTK_WINDOW (dialog)); } return; } str = binding_name (keyval, mask); _terminal_debug_print (TERMINAL_DEBUG_ACCELS, "Edited path %s keyval %s, setting GSettings to %s\n", ke->accel_path, gdk_keyval_name (keyval) ? gdk_keyval_name (keyval) : "null", str); #ifdef MATE_ENABLE_DEBUG _TERMINAL_DEBUG_IF (TERMINAL_DEBUG_ACCELS) { GtkAccelKey old_key; if (gtk_accel_map_lookup_entry (ke->accel_path, &old_key)) { _terminal_debug_print (TERMINAL_DEBUG_ACCELS, " Old entry of path %s is keyval %s mask %x\n", ke->accel_path, gdk_keyval_name (old_key.accel_key), old_key.accel_mods); } else { _terminal_debug_print (TERMINAL_DEBUG_ACCELS, " Failed to look up the old entry of path %s\n", ke->accel_path); } } #endif g_settings_set_string (settings_keybindings, ke->gsettings_key, str); g_free (str); }
static gboolean _g_dbus_error_decode_gerror (const gchar *dbus_name, GQuark *out_error_domain, gint *out_error_code) { gboolean ret; guint n; GString *s; gchar *domain_quark_string; ret = FALSE; s = NULL; if (g_str_has_prefix (dbus_name, "org.gtk.GDBus.UnmappedGError.Quark._")) { s = g_string_new (NULL); for (n = sizeof "org.gtk.GDBus.UnmappedGError.Quark._" - 1; dbus_name[n] != '.' && dbus_name[n] != '\0'; n++) { if (g_ascii_isalnum (dbus_name[n])) { g_string_append_c (s, dbus_name[n]); } else if (dbus_name[n] == '_') { guint nibble_top; guint nibble_bottom; n++; nibble_top = dbus_name[n]; if (nibble_top >= '0' && nibble_top <= '9') nibble_top -= '0'; else if (nibble_top >= 'a' && nibble_top <= 'f') nibble_top -= ('a' - 10); else goto not_mapped; n++; nibble_bottom = dbus_name[n]; if (nibble_bottom >= '0' && nibble_bottom <= '9') nibble_bottom -= '0'; else if (nibble_bottom >= 'a' && nibble_bottom <= 'f') nibble_bottom -= ('a' - 10); else goto not_mapped; g_string_append_c (s, (nibble_top<<4) | nibble_bottom); } else { goto not_mapped; } } if (!g_str_has_prefix (dbus_name + n, ".Code")) goto not_mapped; domain_quark_string = g_string_free (s, FALSE); s = NULL; if (out_error_domain != NULL) *out_error_domain = g_quark_from_string (domain_quark_string); g_free (domain_quark_string); if (out_error_code != NULL) *out_error_code = atoi (dbus_name + n + sizeof ".Code" - 1); ret = TRUE; } not_mapped: if (s != NULL) g_string_free (s, TRUE); return ret; }
static guint dwerg_rc_style_parse(GtkRcStyle *rc_style, GtkSettings *settings, GScanner* scanner) { static GQuark scope_id = 0; DwergRcStyle *theme_data = DWERG_RC_STYLE(rc_style); theme_data->shadow_color_from = malloc(sizeof(GdkColor)); theme_data->shadow_color_to = malloc(sizeof(GdkColor)); guint old_scope; guint token; guint i; /* setup scope, safe old_scope for crash, define tokens */ if (!scope_id) scope_id = g_quark_from_string("dwerg_theme_engine"); old_scope = g_scanner_set_scope(scanner, scope_id); if (!g_scanner_lookup_symbol(scanner, theme_symbols[0].name)) { g_scanner_freeze_symbol_table(scanner); for (i = 0; i < G_N_ELEMENTS(theme_symbols); i++) g_scanner_scope_add_symbol(scanner, scope_id, theme_symbols[i].name, GINT_TO_POINTER(theme_symbols[i].token)); g_scanner_thaw_symbol_table(scanner); } token = g_scanner_peek_next_token(scanner); while (token != G_TOKEN_RIGHT_CURLY) { switch(token) { case TOKEN_SHADOW_COLOR_FROM: g_print("vla\n"); token = g_scanner_get_next_token(scanner); if (token != TOKEN_SHADOW_COLOR_FROM) return token; token = g_scanner_get_next_token(scanner); if (token != G_TOKEN_EQUAL_SIGN) return token; token = gtk_rc_parse_color(scanner, theme_data->shadow_color_from); g_print("ja lekker\n"); break; case TOKEN_SHADOW_COLOR_TO: token = g_scanner_get_next_token(scanner); if (token != TOKEN_SHADOW_COLOR_TO) return token; token = g_scanner_get_next_token(scanner); if (token != G_TOKEN_EQUAL_SIGN) return token; token = gtk_rc_parse_color(scanner, theme_data->shadow_color_to); break; default: g_scanner_get_next_token(scanner); token = G_TOKEN_RIGHT_CURLY; break; } if (token != G_TOKEN_NONE) { g_free(theme_data); return token; } token = g_scanner_peek_next_token(scanner); } /* on no error reset the scope */ g_scanner_get_next_token(scanner); g_scanner_set_scope(scanner, old_scope); return G_TOKEN_NONE; }
GQuark _EscalateUtilErrorQuark() { return g_quark_from_string("escalate-util-error-quark"); }
gboolean dates_import_calendar_data_from_file (ECal *cal, gchar *filename, GError **error) { GError *tmp_error = NULL; GIOChannel *channel = NULL; gchar *line; gsize length; gint num_comp_imported = 0; channel = g_io_channel_new_file (filename, "r", &tmp_error); if (tmp_error != NULL) { g_warning ("Error when opening file: %s", tmp_error->message); g_propagate_error (error, tmp_error); return FALSE; } else { GIOStatus status; icalparser *parser = icalparser_new (); /* set the channel as binary mode and let icalparser_add_line * handle encoding */ g_io_channel_set_encoding (channel, NULL, &tmp_error); if (tmp_error != NULL) { g_warning ("Error when set encoding: %s", tmp_error->message); g_propagate_error (error, tmp_error); g_io_channel_unref (channel); return FALSE; } /* Read the from the file line by line and until EOF */ while ((status = g_io_channel_read_line (channel, &line, &length, NULL, &tmp_error)) == G_IO_STATUS_NORMAL) { icalcomponent *icomp = NULL; /* The parser returns an icalcomponent when it has one */ icomp = icalparser_add_line (parser, line); g_free (line); if (icomp) { gchar *uid = NULL; icalcompiter iter; icalcomponent *subcomp; /* The component is a top-level one and e_cal_create_object only * accepts VEVENTs. Iterate through the VEVENTS. */ iter = icalcomponent_begin_component (icomp, ICAL_VEVENT_COMPONENT); while ((subcomp = icalcompiter_deref (&iter)) != NULL) { if (!e_cal_create_object (cal, subcomp, &uid, &tmp_error)) { g_warning ("Creation of imported event failed: %s", tmp_error->message); g_propagate_error (error, tmp_error); if (parser) icalparser_free (parser); if (icomp) icalcomponent_free (icomp); if (channel) g_io_channel_unref (channel); g_free (uid); return FALSE; } num_comp_imported ++; icalcompiter_next (&iter); g_free (uid); } icalcomponent_free (icomp); } } if (parser) icalparser_free (parser); if (tmp_error != NULL) { g_warning ("Error when reading from file: %s", tmp_error->message); g_propagate_error (error, tmp_error); g_io_channel_unref (channel); return FALSE; } } if (channel) g_io_channel_unref (channel); if (num_comp_imported > 0) { return TRUE; } else { *error = g_error_new_literal (g_quark_from_string ("Dates"), 1, _("No calendar events found.")); return FALSE; } }
static void lsq_archive_command_init(LSQArchiveCommand *archive_command) { archive_command->domain = g_quark_from_string("Command"); }
static DesktopEntryResultCode desktop_entry_load (DesktopEntry *entry) { if (strstr (entry->path, "/menu-xdg/")) return DESKTOP_ENTRY_LOAD_FAIL_OTHER; if (entry->type == DESKTOP_ENTRY_DESKTOP) { GKeyFile *key_file = NULL; DesktopEntryDesktop *entry_desktop = (DesktopEntryDesktop*)entry; const char *categories_str; entry_desktop->appinfo = g_desktop_app_info_new_from_filename (entry->path); if (!G_IS_DESKTOP_APP_INFO (((DesktopEntryDesktop*)entry)->appinfo)) { menu_verbose ("Failed to load \"%s\"\n", entry->path); return DESKTOP_ENTRY_LOAD_FAIL_APPINFO; } categories_str = g_desktop_app_info_get_categories (entry_desktop->appinfo); if (categories_str) { char **categories; int i; categories = g_strsplit (categories_str, ";", -1); entry_desktop->categories = g_new0 (GQuark, g_strv_length (categories) + 1); for (i = 0; categories[i]; i++) entry_desktop->categories[i] = g_quark_from_string (categories[i]); g_strfreev (categories); } key_file = g_key_file_new (); if (!g_key_file_load_from_file (key_file, entry->path, 0, NULL)) entry_desktop->showin = TRUE; else entry_desktop->showin = key_file_get_show_in (key_file); g_key_file_free (key_file); return DESKTOP_ENTRY_LOAD_SUCCESS; } else if (entry->type == DESKTOP_ENTRY_DIRECTORY) { GKeyFile *key_file = NULL; GError *error = NULL; DesktopEntryResultCode rescode = DESKTOP_ENTRY_LOAD_SUCCESS; key_file = g_key_file_new (); if (!g_key_file_load_from_file (key_file, entry->path, 0, &error)) { rescode = DESKTOP_ENTRY_LOAD_FAIL_OTHER; goto out; } if (!desktop_entry_load_directory (entry, key_file, &error)) { rescode = DESKTOP_ENTRY_LOAD_FAIL_OTHER; goto out; } rescode = DESKTOP_ENTRY_LOAD_SUCCESS; out: g_key_file_free (key_file); if (rescode == DESKTOP_ENTRY_LOAD_FAIL_OTHER) { if (error) { menu_verbose ("Failed to load \"%s\": %s\n", entry->path, error->message); g_error_free (error); } else menu_verbose ("Failed to load \"%s\"\n", entry->path); } return rescode; } else g_assert_not_reached (); return DESKTOP_ENTRY_LOAD_FAIL_OTHER; }
static void init() { LttvAttributeValue value; gboolean retval; // Global attributes only used for interaction with main() here. LttvIAttribute *attributes = LTTV_IATTRIBUTE(lttv_global_attributes()); LTTV_TRACES = g_quark_from_string("traces"); LTTV_COMPUTATION = g_quark_from_string("computation"); LTTV_VIEWER_CONSTRUCTORS = g_quark_from_string("viewer_constructors"); LTTV_REQUESTS_QUEUE = g_quark_from_string("requests_queue"); LTTV_REQUESTS_CURRENT = g_quark_from_string("requests_current"); LTTV_NOTIFY_QUEUE = g_quark_from_string("notify_queue"); LTTV_NOTIFY_CURRENT = g_quark_from_string("notify_current"); LTTV_COMPUTATION_TRACESET = g_quark_from_string("computation_traceset"); LTTV_COMPUTATION_TRACESET_CONTEXT = g_quark_from_string("computation_traceset_context"); LTTV_COMPUTATION_SYNC_POSITION = g_quark_from_string("computation_sync_position"); LTTV_BEFORE_CHUNK_TRACESET = g_quark_from_string("before_chunk_traceset"); LTTV_BEFORE_CHUNK_TRACE = g_quark_from_string("before_chunk_trace"); LTTV_BEFORE_CHUNK_TRACEFILE = g_quark_from_string("before_chunk_tracefile"); LTTV_AFTER_CHUNK_TRACESET = g_quark_from_string("after_chunk_traceset"); LTTV_AFTER_CHUNK_TRACE = g_quark_from_string("after_chunk_trace"); LTTV_AFTER_CHUNK_TRACEFILE = g_quark_from_string("after_chunk_tracefile"); LTTV_BEFORE_REQUEST = g_quark_from_string("before_request"); LTTV_AFTER_REQUEST = g_quark_from_string("after_request"); LTTV_EVENT_HOOK = g_quark_from_string("event_hook"); LTTV_EVENT_HOOK_BY_ID_CHANNEL = g_quark_from_string("event_hook_by_id_channel"); LTTV_HOOK_ADDER = g_quark_from_string("hook_adder"); LTTV_HOOK_REMOVER = g_quark_from_string("hook_remover"); LTTV_IN_PROGRESS = g_quark_from_string("in_progress"); LTTV_READY = g_quark_from_string("ready"); LTTV_LOCK = g_quark_from_string("lock"); g_debug("GUI init()"); lttv_option_add("trace", 't', "add a trace to the trace set to analyse", "pathname of the directory containing the trace", LTTV_OPT_STRING, &a_trace, lttv_trace_option, NULL); a_live = FALSE; lttv_option_add("live", 0, "define if the traceset is receiving live informations", "", LTTV_OPT_NONE, &a_live, NULL, NULL); retval= lttv_iattribute_find_by_path(attributes, "hooks/main/before", LTTV_POINTER, &value); g_assert(retval); g_assert((main_hooks = *(value.v_pointer)) != NULL); lttv_hooks_add(main_hooks, window_creation_hook, NULL, LTTV_PRIO_DEFAULT); #ifdef BABEL_CLEANUP { /* Register state calculator */ LttvHooks *hook_adder = lttv_hooks_new(); lttv_hooks_add(hook_adder, lttv_state_save_hook_add_event_hooks, NULL, LTTV_PRIO_DEFAULT); lttv_hooks_add(hook_adder, lttv_state_hook_add_event_hooks, NULL, LTTV_PRIO_DEFAULT); LttvHooks *hook_remover = lttv_hooks_new(); lttv_hooks_add(hook_remover, lttv_state_save_hook_remove_event_hooks, NULL, LTTV_PRIO_DEFAULT); lttv_hooks_add(hook_remover, lttv_state_hook_remove_event_hooks, NULL, LTTV_PRIO_DEFAULT); /* Add state computation background hook adder to attributes */ lttvwindowtraces_register_computation_hooks(g_quark_from_string("state"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, hook_adder, hook_remover); } { /* Register statistics calculator */ LttvHooks *hook_adder = lttv_hooks_new(); lttv_hooks_add(hook_adder, lttv_stats_hook_add_event_hooks, NULL, LTTV_PRIO_DEFAULT); lttv_hooks_add(hook_adder, lttv_state_hook_add_event_hooks, NULL, LTTV_PRIO_DEFAULT); LttvHooks *hook_remover = lttv_hooks_new(); lttv_hooks_add(hook_remover, lttv_stats_hook_remove_event_hooks, NULL, LTTV_PRIO_DEFAULT); lttv_hooks_add(hook_remover, lttv_state_hook_remove_event_hooks, NULL, LTTV_PRIO_DEFAULT); LttvHooks *after_request = lttv_hooks_new(); lttv_hooks_add(after_request, lttv_stats_sum_traceset_hook, NULL, LTTV_PRIO_DEFAULT); /* Add state computation background hook adder to attributes */ lttvwindowtraces_register_computation_hooks(g_quark_from_string("stats"), NULL, NULL, NULL, NULL, NULL, NULL, NULL, after_request, NULL, NULL, hook_adder, hook_remover); } #endif /* BABEL_CLEANUP */ }
static void gwy_app_file_chooser_add_type_list(GwyAppFileChooser *chooser) { GtkWidget *vbox, *scwin; GtkTreeView *treeview; GtkFileChooserAction action; GtkRequisition req; GtkTreeSelection *selection; GtkTreeViewColumn *column; GtkCellRenderer *renderer; GtkListStore *store; GtkTreeIter iter; gboolean expanded = FALSE; gboolean filter = FALSE; gchar *key; g_object_get(chooser, "action", &action, NULL); key = g_strconcat(chooser->prefix, "/type", NULL); chooser->type_key = g_quark_from_string(key); g_free(key); store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); gtk_list_store_append(store, &iter); switch (action) { case GTK_FILE_CHOOSER_ACTION_SAVE: gtk_list_store_set(store, &iter, COLUMN_FILETYPE, "", COLUMN_LABEL, _("Automatic by extension"), -1); gwy_app_file_chooser_add_types(store, GWY_FILE_OPERATION_SAVE, FALSE); gwy_app_file_chooser_add_types(store, GWY_FILE_OPERATION_EXPORT, FALSE); break; case GTK_FILE_CHOOSER_ACTION_OPEN: gtk_list_store_set(store, &iter, COLUMN_FILETYPE, "", COLUMN_LABEL, _("Automatically detected"), -1); gwy_app_file_chooser_add_types(store, GWY_FILE_OPERATION_LOAD, TRUE); break; default: g_assert_not_reached(); break; } chooser->expander = gtk_expander_new(NULL); gtk_expander_set_use_underline(GTK_EXPANDER(chooser->expander), TRUE); gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(chooser), chooser->expander); key = g_strconcat(chooser->prefix, "/expanded", NULL); gwy_container_gis_boolean_by_name(gwy_app_settings_get(), key, &expanded); g_free(key); gtk_expander_set_expanded(GTK_EXPANDER(chooser->expander), expanded); g_signal_connect_swapped(chooser->expander, "notify::expanded", G_CALLBACK(gwy_app_file_chooser_expanded), chooser); vbox = gtk_vbox_new(FALSE, 4); gtk_container_add(GTK_CONTAINER(chooser->expander), vbox); scwin = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scwin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(vbox), scwin, TRUE, TRUE, 0); chooser->type_list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); treeview = GTK_TREE_VIEW(chooser->type_list); g_object_unref(store); gtk_tree_view_set_headers_visible(treeview, FALSE); gtk_container_add(GTK_CONTAINER(scwin), chooser->type_list); column = gtk_tree_view_column_new(); gtk_tree_view_append_column(treeview, column); renderer = gtk_cell_renderer_text_new(); gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(column), renderer, TRUE); gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(column), renderer, "text", COLUMN_LABEL); selection = gtk_tree_view_get_selection(treeview); gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); g_signal_connect_swapped(selection, "changed", G_CALLBACK(gwy_app_file_chooser_type_changed), chooser); if (action == GTK_FILE_CHOOSER_ACTION_OPEN) { chooser->filter_enable = gtk_check_button_new_with_mnemonic(_("Show only loadable files")); key = g_strconcat(chooser->prefix, "/filter", NULL); gwy_container_gis_boolean_by_name(gwy_app_settings_get(), key, &filter); g_free(key); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chooser->filter_enable), filter); gtk_box_pack_start(GTK_BOX(vbox), chooser->filter_enable, FALSE, FALSE, 0); g_signal_connect_swapped(chooser->filter_enable, "toggled", G_CALLBACK(gwy_app_file_chooser_filter_toggled), chooser); gwy_app_file_chooser_filter_toggled(chooser, GTK_TOGGLE_BUTTON(chooser->filter_enable)); } /* Give it some reasonable size. FIXME: hack. */ gtk_widget_show_all(vbox); gtk_widget_size_request(scwin, &req); gtk_widget_set_size_request(scwin, -1, req.height + 100); gwy_app_file_chooser_select_type(chooser); gwy_app_file_chooser_type_changed(chooser, selection); }
/* Returns a structure with information we will use to rendering given the * #PangoFont. This is computed once per font and cached for later retrieval. */ static ThaiFontInfo * thai_x_get_font_info (PangoFont *font) { static const char *charsets[] = { "tis620-2", "tis620-1", "tis620-0", "xtis620.2529-1", "xtis-0", "tis620.2533-1", "tis620.2529-1", "iso8859-11", "iso10646-1", }; static const int charset_types[] = { THAI_FONT_TIS_WIN, THAI_FONT_TIS_MAC, THAI_FONT_TIS, THAI_FONT_XTIS, THAI_FONT_XTIS, THAI_FONT_TIS, THAI_FONT_TIS, THAI_FONT_TIS, THAI_FONT_ISO10646 }; ThaiFontInfo *font_info; GQuark info_id = g_quark_from_string ("thai-font-info"); font_info = g_object_get_qdata (G_OBJECT (font), info_id); if (!font_info) { /* No cached information not found, so we need to compute it * from scratch */ PangoXSubfont *subfont_ids; gint *subfont_charsets; gint n_subfonts, i; font_info = g_new (ThaiFontInfo, 1); font_info->font = font; font_info->font_set = THAI_FONT_NONE; g_object_set_qdata_full (G_OBJECT (font), info_id, font_info, (GDestroyNotify)g_free); n_subfonts = pango_x_list_subfonts (font, (char **)charsets, G_N_ELEMENTS (charsets), &subfont_ids, &subfont_charsets); for (i=0; i < n_subfonts; i++) { ThaiFontSet font_set = charset_types[subfont_charsets[i]]; if (font_set != THAI_FONT_ISO10646 || pango_x_has_glyph (font, PANGO_X_MAKE_GLYPH (subfont_ids[i], 0xe01))) { font_info->font_set = font_set; font_info->subfont = subfont_ids[i]; break; } } g_free (subfont_ids); g_free (subfont_charsets); font_info->make_glyph = thai_x_make_glyph; font_info->make_unknown_glyph = thai_x_make_unknown_glyph; font_info->has_glyph = thai_x_has_glyph; } return font_info; }
static guint mgicchikn_rc_style_parse (GtkRcStyle * rc_style, GtkSettings * settings, GScanner * scanner) { MgicChiknRcStyle *style; static GQuark scope = 0; GQuark old_scope; guint token; gint i; g_return_val_if_fail (rc_style != NULL, G_TOKEN_NONE); g_return_val_if_fail (MGICCHIKN_IS_RC_STYLE (rc_style), G_TOKEN_NONE); style = MGICCHIKN_RC_STYLE (rc_style); if (!scope) scope = g_quark_from_string ("theme_engine"); old_scope = g_scanner_set_scope (scanner, scope); /* If we don't have the symbol table inside scanner, put it in there */ if (!g_scanner_lookup_symbol (scanner, symbols[0].name)) { for (i = 0; i < G_N_ELEMENTS (symbols); i++) { g_scanner_scope_add_symbol (scanner, scope, symbols[i].name, GUINT_TO_POINTER (symbols[i].token)); } } token = g_scanner_peek_next_token (scanner); while (token != G_TOKEN_RIGHT_CURLY) { switch (token) { case MGICCHIKN_TOKEN_STOCK_IMAGE_TRANSPARENCY: token = mgicchikn_rc_parse_stock_image_transparency (style, scanner); break; case MGICCHIKN_TOKEN_STOCK_IMAGE_SATURATION: token = mgicchikn_rc_parse_stock_image_saturation (style, scanner); break; case MGICCHIKN_TOKEN_STOCK_IMAGE_BRIGHTNESS: token = mgicchikn_rc_parse_stock_image_brightness (style, scanner); break; case MGICCHIKN_TOKEN_SHADOW: token = mgicchikn_rc_parse_shadow (style, scanner); break; case MGICCHIKN_TOKEN_SHADOW_WIDTH: token = mgicchikn_rc_parse_shadow_width (style, scanner); break; case MGICCHIKN_TOKEN_GRIPPY_STYLE: token = mgicchikn_rc_parse_grippy_style (style, scanner); break; case MGICCHIKN_TOKEN_FONT_SHADOW: token = mgicchikn_rc_parse_font_shadow (style, scanner); break; case MGICCHIKN_TOKEN_FONT_UNDERLINE: token = mgicchikn_rc_parse_font_underline (style, scanner); break; case MGICCHIKN_TOKEN_CHECK_IMAGE: token = mgicchikn_rc_parse_check_image (style, settings, scanner); break; case MGICCHIKN_TOKEN_RADIO_IMAGE: token = mgicchikn_rc_parse_radio_image (style, settings, scanner); break; default: break; } if (token != G_TOKEN_NONE) return token; token = g_scanner_peek_next_token (scanner); } g_scanner_get_next_token (scanner); g_scanner_set_scope (scanner, old_scope); return G_TOKEN_NONE; }
void ags_test_init(int *argc, char ***argv, gchar *conf_str) { AgsConfig *config; gchar *filename; gboolean single_thread_enabled; gboolean builtin_theme_disabled; guint i; #ifdef AGS_WITH_RT struct sched_param param; struct rlimit rl; #endif struct passwd *pw; gchar *wdir, *config_file; gchar *rc_filename; gchar *base_dir; gchar *str, *data_dir; gchar path[PATH_MAX]; uint32_t size = sizeof(path); uid_t uid; int result; const rlim_t kStackSize = 64L * 1024L * 1024L; // min stack size = 64 Mb base_dir = strdup(SRCDIR); printf("base dir %s\n", base_dir); /* set some environment variables */ sprintf(path, "%s/gsequencer.share/styles", base_dir); data_dir = realpath(path, NULL); str = malloc(PATH_MAX * sizeof(gchar)); sprintf(str, "AGS_RC_FILENAME=%s/ags.rc", data_dir); putenv(str); sprintf(path, "%s/gsequencer.share/images", base_dir); data_dir = realpath(path, NULL); str = malloc(PATH_MAX * sizeof(gchar)); sprintf(str, "AGS_ANIMATION_FILENAME=%s/ags_supermoon-800x450.png", data_dir); putenv(str); sprintf(path, "%s/gsequencer.share/images", base_dir); data_dir = realpath(path, NULL); str = malloc(PATH_MAX * sizeof(gchar)); sprintf(str, "AGS_LOGO_FILENAME=%s/ags.png", data_dir); putenv(str); sprintf(path, "%s", base_dir); data_dir = realpath(path, NULL); str = malloc(PATH_MAX * sizeof(gchar)); sprintf(str, "AGS_LICENSE_FILENAME=%s/COPYING", data_dir); putenv(str); /* gettext */ setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); /* parameters */ single_thread_enabled = FALSE; builtin_theme_disabled = FALSE; // g_log_set_fatal_mask("GLib", // "Gtk" , // // G_LOG_LEVEL_CRITICAL); // G_LOG_LEVEL_WARNING #ifdef AGS_WITH_RT result = getrlimit(RLIMIT_STACK, &rl); /* set stack size 64M */ if(result == 0){ if(rl.rlim_cur < kStackSize){ rl.rlim_cur = kStackSize; result = setrlimit(RLIMIT_STACK, &rl); if(result != 0){ //TODO:JK } } } param.sched_priority = GSEQUENCER_RT_PRIORITY; if(sched_setscheduler(0, SCHED_FIFO, ¶m) == -1) { perror("sched_setscheduler failed"); } #endif //#ifdef AGS_WITH_X11 XInitThreads(); //#endif /* parse command line parameter */ filename = NULL; for(i = 0; i < argc[0]; i++){ if(!strncmp(argv[0][i], "--help", 7)){ printf("GSequencer is an audio sequencer and notation editor\n\n"); printf("Usage:\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n\n", "Report bugs to <*****@*****.**>\n", "--filename file open file", "--single-thread run in single thread mode", "--no-builtin-theme disable built-in theme", "--help display this help and exit", "--version output version information and exit"); exit(0); }else if(!strncmp(argv[0][i], "--version", 10)){ printf("GSequencer %s\n\n", AGS_VERSION); printf("%s\n%s\n%s\n\n", "Copyright (C) 2005-2017 Joël Krähemann", "This is free software; see the source for copying conditions. There is NO", "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."); printf("Written by Joël Krähemann\n"); exit(0); }else if(!strncmp(argv[0][i], "--single-thread", 16)){ single_thread_enabled = TRUE; }else if(!strncmp(argv[0][i], "--no-builtin-theme", 19)){ builtin_theme_disabled = TRUE; }else if(!strncmp(argv[0][i], "--filename", 11)){ filename = *argv[i + 1]; i++; } } uid = getuid(); pw = getpwuid(uid); /* parse rc file */ if(!builtin_theme_disabled){ rc_filename = g_strdup_printf("%s/%s/ags.rc", pw->pw_dir, AGS_DEFAULT_DIRECTORY); if(!g_file_test(rc_filename, G_FILE_TEST_IS_REGULAR)){ g_free(rc_filename); #ifdef AGS_RC_FILENAME rc_filename = g_strdup(AGS_RC_FILENAME); #else if((rc_filename = getenv("AGS_RC_FILENAME")) == NULL){ rc_filename = g_strdup_printf("%s%s", DESTDIR, "/gsequencer/styles/ags.rc"); }else{ rc_filename = g_strdup(rc_filename); } #endif } gtk_rc_parse(rc_filename); g_free(rc_filename); } /**/ LIBXML_TEST_VERSION; ags_gui_init(argc, argv); gtk_init(argc, argv); if(!builtin_theme_disabled){ g_object_set(gtk_settings_get_default(), "gtk-theme-name", "Raleigh", NULL); g_signal_handlers_block_matched(gtk_settings_get_default(), G_SIGNAL_MATCH_DETAIL, g_signal_lookup("set-property", GTK_TYPE_SETTINGS), g_quark_from_string("gtk-theme-name"), NULL, NULL, NULL); } #ifdef AGS_WITH_LIBINSTPATCH ipatch_init(); #endif /* setup */ wdir = g_strdup_printf("%s/%s", pw->pw_dir, AGS_DEFAULT_DIRECTORY); config_file = g_strdup_printf("%s/%s", wdir, AGS_DEFAULT_CONFIG); config = ags_config_get_instance(); if(conf_str != NULL){ ags_config_load_from_data(config, conf_str, strlen(conf_str)); }else{ ags_config_load_from_file(config, config_file); } g_free(wdir); g_free(config_file); }
static void gxi_check_file (GncXmlImportData *data) { if (!data->encodings) { gboolean is_utf8; const gchar *locale_enc; gchar *enc_string, **enc_array, **enc_cursor; gpointer enc_ptr; GIConv iconv; /* first locale encoding */ is_utf8 = g_get_charset (&locale_enc); enc_string = g_ascii_strup (locale_enc, -1); enc_ptr = GUINT_TO_POINTER (g_quark_from_string (enc_string)); g_free (enc_string); data->encodings = g_list_append (NULL, enc_ptr); /* add utf-8 */ if (!is_utf8) { enc_ptr = GUINT_TO_POINTER (g_quark_from_string ("UTF-8")); data->encodings = g_list_append (data->encodings, enc_ptr); } /* Translators: Please insert encodings here that are typically used in your * locale, separated by spaces. No need for ASCII or UTF-8, check `locale -m` * for assistance with spelling. */ enc_array = g_strsplit (_("ISO-8859-1 KOI8-U"), " ", 0); /* loop through typical encodings */ for (enc_cursor = enc_array; *enc_cursor; enc_cursor++) { if (!**enc_cursor) continue; enc_string = g_ascii_strup (*enc_cursor, -1); enc_ptr = GUINT_TO_POINTER (g_quark_from_string (enc_string)); if (!g_list_find (data->encodings, enc_ptr)) { /* test whether we like this encoding */ iconv = g_iconv_open ("UTF-8", enc_string); if (iconv != (GIConv) - 1) /* we like it */ data->encodings = g_list_append (data->encodings, enc_ptr); g_iconv_close (iconv); } g_free (enc_string); } g_strfreev (enc_array); } if (!data->default_encoding) { /* choose top one */ data->default_encoding = GPOINTER_TO_UINT (data->encodings->data); } if (!data->choices) { data->choices = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) conv_free); } gxi_ambiguous_info_destroy (data); /* analyze file */ data->n_impossible = gnc_xml2_find_ambiguous ( data->filename, data->encodings, &data->unique, &data->ambiguous_ht, NULL); if (data->n_impossible != -1) { /* sort ambiguous words */ g_hash_table_foreach (data->ambiguous_ht, (GHFunc)ambiguous_list_insert, data); gxi_sort_ambiguous_list (data); } }
/** * _rb_player_emit_event: * @player: a #RBPlayer implementation * @stream_data: data associated with the stream * @name: event name * @data: event data * * Emits the 'event' signal for a stream. * To be used by implementations only. */ void _rb_player_emit_event (RBPlayer *player, gpointer stream_data, const char *name, gpointer data) { g_signal_emit (player, signals[EVENT], g_quark_from_string (name), stream_data, data); }
/** * {@inheritDoc} */ static void plank_items_dock_item_preferences_real_verify (PlankServicesPreferences* base, const gchar* prop) { PlankItemsDockItemPreferences * self; const gchar* _tmp0_ = NULL; const gchar* _tmp1_ = NULL; GQuark _tmp3_ = 0U; static GQuark _tmp2_label0 = 0; GError * _inner_error_ = NULL; self = (PlankItemsDockItemPreferences*) base; g_return_if_fail (prop != NULL); _tmp0_ = prop; _tmp1_ = _tmp0_; _tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_); if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("Launcher")))) { switch (0) { default: { const gchar* _tmp4_ = NULL; gboolean _tmp5_ = FALSE; _tmp4_ = self->priv->_Launcher; _tmp5_ = g_str_has_prefix (_tmp4_, "/"); if (_tmp5_) { { gchar* _tmp6_ = NULL; const gchar* _tmp7_ = NULL; gchar* _tmp8_ = NULL; _tmp7_ = self->priv->_Launcher; _tmp8_ = g_filename_to_uri (_tmp7_, NULL, &_inner_error_); _tmp6_ = _tmp8_; if (_inner_error_ != NULL) { if (_inner_error_->domain == G_CONVERT_ERROR) { goto __catch28_g_convert_error; } g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } plank_items_dock_item_preferences_set_Launcher (self, _tmp6_); _g_free0 (_tmp6_); } goto __finally28; __catch28_g_convert_error: { GError* e = NULL; GError* _tmp9_ = NULL; const gchar* _tmp10_ = NULL; e = _inner_error_; _inner_error_ = NULL; _tmp9_ = e; _tmp10_ = _tmp9_->message; g_warning ("DockItemPreferences.vala:74: %s", _tmp10_); _g_error_free0 (e); } __finally28: if (_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code); g_clear_error (&_inner_error_); return; } } break; } } } }
static void nautilus_column_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) { NautilusColumn *column; column = NAUTILUS_COLUMN (object); switch (param_id) { case PROP_NAME: { g_free (column->name); column->name = g_strdup (g_value_get_string (value)); g_object_notify (object, "name"); } break; case PROP_ATTRIBUTE: { column->attribute = g_quark_from_string (g_value_get_string (value)); g_object_notify (object, "attribute"); g_object_notify (object, "attribute_q"); } break; case PROP_LABEL: { g_free (column->label); column->label = g_strdup (g_value_get_string (value)); g_object_notify (object, "label"); } break; case PROP_DESCRIPTION: { g_free (column->description); column->description = g_strdup (g_value_get_string (value)); g_object_notify (object, "description"); } break; case PROP_XALIGN: { column->xalign = g_value_get_float (value); g_object_notify (object, "xalign"); } break; case PROP_DEFAULT_SORT_ORDER: { column->default_sort_order = g_value_get_enum (value); g_object_notify (object, "default-sort-order"); } break; default: { G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); } break; } }