Beispiel #1
0
static gboolean
ibus_m17n_scan_class_name (const gchar *class_name,
                           gchar      **lang,
                           gchar      **name)
{
    gchar *p;

    g_return_val_if_fail (g_str_has_prefix (class_name, "IBusM17N"), FALSE);
    g_return_val_if_fail (g_str_has_suffix (class_name, "Engine"), FALSE);

    /* Strip prefix and suffix */
    p = *lang = g_strdup (class_name + 8);
    p = g_strrstr (p, "Engine");
    *p = '\0';

    /* Find the start position of <Name> */
    while (!g_ascii_isupper (*--p) && p > *lang)
        ;
    g_return_val_if_fail (p > *lang, FALSE);
    *name = g_strdup (p);
    *p = '\0';

    *lang[0] = g_ascii_tolower (*lang[0]);
    *name[0] = g_ascii_tolower (*name[0]);

    return TRUE;
}
Beispiel #2
0
static gboolean _sql_identifier_is_valid_char(gchar c)
{
  return ((c == '.') ||
          (c == '_') ||
          (c >= '0' && c <= '9') ||
          (g_ascii_tolower(c) >= 'a' && g_ascii_tolower(c) <= 'z'));
}
Beispiel #3
0
eTokType parser_number(sParser* parse){ 
  //handle the sign
  gboolean negative;
  if('-'==*parse->ptr){
    parser_get_char(parse); //eat the -
    negative=TRUE;
    parser_ws(parse); //- 4 should be ok now
  } else 
    negative = FALSE;
  
  //now parse the digits
  double value = parser_integer(parse);
  if('.'==*parse->ptr){
    parser_get_char(parse); //eat .
    value += parser_fraction(parse);
  }
  //now value is good.  Handle mm and mil units
  if('m'==g_ascii_tolower(*parse->ptr)){
    if('m'==g_ascii_tolower(*(parse->ptr+1))) {
      parser_get_char(parse);parser_get_char(parse); //eat mm
      value = value*3937.007874015748;
    } else if('i'==g_ascii_tolower(*(parse->ptr+1))) {
        if('l'==g_ascii_tolower(*(parse->ptr+2))) {
          parser_get_char(parse);parser_get_char(parse);parser_get_char(parse); //eat mil
          value = value * 100.0;
        }
    }
  }
  if(negative) value =0.0-value;
  parse->data.number = value;
  return parse->type=TOK_NUMBER;
}
Beispiel #4
0
/*
 * pattern matching function for filenames.  Each occurrence of the *
 * pattern causes a recursion level.
 */
static int
match(const gchar *name, gchar *pat, gchar *patend, gboolean ignorecase)
{
	gchar c;

	while (pat < patend) {
		c = *pat++;
		switch (c & M_MASK) {
		case M_ALL:
			if (pat == patend)
				return(1);
			do {
				if (match(name, pat, patend, ignorecase))
					return(1);
			} while (*name++ != EOS);
			return(0);
		case M_ONE:
			if (*name++ == EOS)
				return(0);
			break;
		default:
			if (ignorecase) {
				if (g_ascii_tolower (*name++) != g_ascii_tolower (c))
					return(0);
			} else {
				if (*name++ != c)
					return(0);
			}
			
			break;
		}
	}
	return(*name == EOS);
}
Beispiel #5
0
static char *
panel_layout_object_generate_id (const char *iid)
{
        GString    *generated_id;
        const char *applet;
        char        old;

        applet = g_strrstr (iid, "::");

        if (applet == NULL)
                return NULL;

        generated_id = g_string_new ("");
        applet += 2;
        old = applet[0];

        while (applet[0] != '\0') {
                if (g_ascii_isupper (applet[0]) && old != ':' && g_ascii_islower (applet[1]) && generated_id->len != 0) {
                        g_string_append_printf (generated_id, "-%c", g_ascii_tolower (applet[0]));
                } else {
                        g_string_append_c (generated_id, applet[0] != ':' ? g_ascii_tolower (applet[0]) : '-');
                }

                old = applet[0];
                applet += 1;
        }

        return g_string_free (generated_id, FALSE);
}
static gboolean get_config (GKeyFile *pKeyFile, CairoConfigTaskBar *pTaskBar)
{
	gboolean bFlushConfFileNeeded = FALSE;
	
	pTaskBar->bShowAppli = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "show applications", &bFlushConfFileNeeded, TRUE, "Applications", NULL);
	
	///pTaskBar->bUniquePid = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "unique PID", &bFlushConfFileNeeded, FALSE, "Applications", NULL);
	
	pTaskBar->bGroupAppliByClass = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "group by class", &bFlushConfFileNeeded, TRUE, "Applications", NULL);
	pTaskBar->cGroupException = cairo_dock_get_string_key_value (pKeyFile, "TaskBar", "group exception", &bFlushConfFileNeeded, "pidgin;xchat", NULL, NULL);
	if (pTaskBar->cGroupException)
	{
		int i;
		for (i = 0; pTaskBar->cGroupException[i] != '\0'; i ++)
			pTaskBar->cGroupException[i] = g_ascii_tolower (pTaskBar->cGroupException[i]);
	}
	
	pTaskBar->iAppliMaxNameLength = cairo_dock_get_integer_key_value (pKeyFile, "TaskBar", "max name length", &bFlushConfFileNeeded, 15, "Applications", NULL);

	pTaskBar->bMinimizeOnClick = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "minimize on click", &bFlushConfFileNeeded, TRUE, "Applications", NULL);
	pTaskBar->bCloseAppliOnMiddleClick = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "close on middle click", &bFlushConfFileNeeded, TRUE, "Applications", NULL);

	pTaskBar->bHideVisibleApplis = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "hide visible", &bFlushConfFileNeeded, FALSE, "Applications", NULL);
	pTaskBar->fVisibleAppliAlpha = cairo_dock_get_double_key_value (pKeyFile, "TaskBar", "visibility alpha", &bFlushConfFileNeeded, .35, "Applications", NULL);  // >0 <=> les fenetres minimisees sont transparentes.
	if (pTaskBar->bHideVisibleApplis && pTaskBar->fVisibleAppliAlpha < 0)
		pTaskBar->fVisibleAppliAlpha = 0.;  // on inhibe ce parametre, puisqu'il ne sert alors a rien.
	else if (pTaskBar->fVisibleAppliAlpha > .6)
		pTaskBar->fVisibleAppliAlpha = .6;
	else if (pTaskBar->fVisibleAppliAlpha < -.6)
		pTaskBar->fVisibleAppliAlpha = -.6;
	pTaskBar->bAppliOnCurrentDesktopOnly = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "current desktop only", &bFlushConfFileNeeded, FALSE, "Applications", NULL);
	
	pTaskBar->bDemandsAttentionWithDialog = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "demands attention with dialog", &bFlushConfFileNeeded, TRUE, "Applications", NULL);
	pTaskBar->iDialogDuration = cairo_dock_get_integer_key_value (pKeyFile, "TaskBar", "duration", &bFlushConfFileNeeded, 2, NULL, NULL);
	pTaskBar->cAnimationOnDemandsAttention = cairo_dock_get_string_key_value (pKeyFile, "TaskBar", "animation on demands attention", &bFlushConfFileNeeded, "fire", NULL, NULL);
	gchar *cForceDemandsAttention = cairo_dock_get_string_key_value (pKeyFile, "TaskBar", "force demands attention", &bFlushConfFileNeeded, "pidgin;xchat", NULL, NULL);
	pTaskBar->cForceDemandsAttention = g_ascii_strdown (cForceDemandsAttention, -1);
	g_free (cForceDemandsAttention);
	
	pTaskBar->cAnimationOnActiveWindow = cairo_dock_get_string_key_value (pKeyFile, "TaskBar", "animation on active window", &bFlushConfFileNeeded, "wobbly", NULL, NULL);
	
	pTaskBar->bMixLauncherAppli = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "mix launcher appli", &bFlushConfFileNeeded, TRUE, NULL, NULL);
	pTaskBar->bDrawIndicatorOnAppli = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "indic on appli", &bFlushConfFileNeeded, FALSE, NULL, NULL);
	pTaskBar->bOverWriteXIcons = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "overwrite xicon", &bFlushConfFileNeeded, TRUE, NULL, NULL);
	pTaskBar->cOverwriteException = cairo_dock_get_string_key_value (pKeyFile, "TaskBar", "overwrite exception", &bFlushConfFileNeeded, "pidgin;xchat", NULL, NULL);
	if (pTaskBar->cOverwriteException)
	{
		int i;
		for (i = 0; pTaskBar->cOverwriteException[i] != '\0'; i ++)
			pTaskBar->cOverwriteException[i] = g_ascii_tolower (pTaskBar->cOverwriteException[i]);
	}
	pTaskBar->bShowThumbnail = cairo_dock_get_boolean_key_value (pKeyFile, "TaskBar", "window thumbnail", &bFlushConfFileNeeded, TRUE, NULL, NULL);
	if (pTaskBar->bShowThumbnail && ! cairo_dock_xcomposite_is_available ())
	{
		cd_warning ("Sorry but either your X server does not have the XComposite extension, or your version of Cairo-Dock was not built with the support of XComposite.\n You can't have window thumbnails in the dock");
		pTaskBar->bShowThumbnail = FALSE;
	}

	return bFlushConfFileNeeded;
}
/* _mate_vfs_istr_has_suffix
 * copy-pasted from Caja
 */
gboolean
_mate_vfs_istr_has_suffix (const char *haystack, const char *needle)
{
	const char *h, *n;
	char hc, nc;

	if (needle == NULL) {
		return TRUE;
	}
	if (haystack == NULL) {
		return needle[0] == '\0';
	}
		
	/* Eat one character at a time. */
	h = haystack + strlen (haystack);
	n = needle + strlen (needle);
	do {
		if (n == needle) {
			return TRUE;
		}
		if (h == haystack) {
			return FALSE;
		}
		hc = *--h;
		nc = *--n;
		hc = g_ascii_tolower (hc);
		nc = g_ascii_tolower (nc);
	} while (hc == nc);
	return FALSE;
}
Beispiel #8
0
static gint
parse_boolean (char *v)
{
  gchar c0, c1;
  
  c0 = *v;
  if (g_ascii_isupper ((int)c0))
    c0 = g_ascii_tolower (c0);
  if (c0 == 't' || c0 == 'y' || c0 == '1')
    return 1;
  if (c0 == 'f' || c0 == 'n' || c0 == '0')
    return 0;
  if (c0 == 'o')
    {
      c1 = v[1];
      if (g_ascii_isupper ((int)c1))
	c1 = g_ascii_tolower (c1);
      if (c1 == 'n')
	return 1;
      if (c1 == 'f')
	return 0;
    }
  
  return -1;
}
Beispiel #9
0
/* we want to escape text in general, but retain basic markup like
 * <i></i>, <u></u>, and <b></b>. The easiest and safest way is to
 * just unescape a white list of allowed markups again after
 * escaping everything (the text between these simple markers isn't
 * necessarily escaped, so it seems best to do it like this) */
static void
subrip_unescape_formatting (gchar * txt)
{
  gchar *pos;

  for (pos = txt; pos != NULL && *pos != '\0'; ++pos) {
    if (g_ascii_strncasecmp (pos, "&lt;u&gt;", 9) == 0 ||
        g_ascii_strncasecmp (pos, "&lt;i&gt;", 9) == 0 ||
        g_ascii_strncasecmp (pos, "&lt;b&gt;", 9) == 0) {
      pos[0] = '<';
      pos[1] = g_ascii_tolower (pos[4]);
      pos[2] = '>';
      /* move NUL terminator as well */
      g_memmove (pos + 3, pos + 9, strlen (pos + 9) + 1);
      pos += 2;
    }
  }

  for (pos = txt; pos != NULL && *pos != '\0'; ++pos) {
    if (g_ascii_strncasecmp (pos, "&lt;/u&gt;", 10) == 0 ||
        g_ascii_strncasecmp (pos, "&lt;/i&gt;", 10) == 0 ||
        g_ascii_strncasecmp (pos, "&lt;/b&gt;", 10) == 0) {
      pos[0] = '<';
      pos[1] = '/';
      pos[2] = g_ascii_tolower (pos[5]);
      pos[3] = '>';
      /* move NUL terminator as well */
      g_memmove (pos + 4, pos + 10, strlen (pos + 10) + 1);
      pos += 3;
    }
  }
}
Beispiel #10
0
gboolean
metautils_str_has_caseprefix (const char *str, const char *prefix)
{
	const char *s = str, *p = prefix;
	for (; *s && *p ;++s,++p) {
		if (g_ascii_tolower (*s) != g_ascii_tolower (*p))
			return FALSE;
	}
	return !*p;
}
Beispiel #11
0
void hexstr_to_sha1 (uint8_t *out, const char *in)
{
    int i;
    static const char hex[] = "0123456789abcdef";

    for (i=0; i<20; ++i) {
        const int hi = strchr (hex, g_ascii_tolower (*in++)) - hex;
        const int lo = strchr (hex, g_ascii_tolower (*in++)) - hex;
        *out++ = (uint8_t)((hi<<4) | lo);
    }
}
static void
thunar_sbr_number_renamer_update (ThunarSbrNumberRenamer *number_renamer)
{
  gboolean invalid = TRUE;
  GdkColor back;
  GdkColor text;
  gchar   *endp;
  guint    number;

  /* check whether "start" is valid for the "mode" */
  if (number_renamer->mode < THUNAR_SBR_NUMBER_MODE_ABC)
    {
      /* "start" must be a positive number */
      number = strtoul (number_renamer->start, &endp, 10);
      invalid = (endp <= number_renamer->start || *endp != '\0');
    }
  else if (number_renamer->mode == THUNAR_SBR_NUMBER_MODE_ABC)
    {
      /* "start" property must be 'a', 'b', 'c', etc. */
      invalid = (strlen (number_renamer->start) != 1
              || g_ascii_tolower (*number_renamer->start) < 'a'
              || g_ascii_tolower (*number_renamer->start) > 'z');
    }

  /* check if the start entry is realized */
  if (GTK_WIDGET_REALIZED (number_renamer->start_entry))
    {
      /* check if the "start" value is valid */
      if (G_UNLIKELY (invalid))
        {
          /* if GTK+ wouldn't be that stupid with style properties and 
           * type plugins, this would be themable, but unfortunately
           * GTK+ is totally broken, and so it's hardcoded.
           */
          gdk_color_parse ("#ff6666", &back);
          gdk_color_parse ("White", &text);

          /* setup a red background/text color to indicate the error */
          gtk_widget_modify_base (number_renamer->start_entry, GTK_STATE_NORMAL, &back);
          gtk_widget_modify_text (number_renamer->start_entry, GTK_STATE_NORMAL, &text);
        }
      else
        {
          /* reset background/text color */
          gtk_widget_modify_base (number_renamer->start_entry, GTK_STATE_NORMAL, NULL);
          gtk_widget_modify_text (number_renamer->start_entry, GTK_STATE_NORMAL, NULL);
        }
    }

  /* notify everybody that we have a new state */
  thunarx_renamer_changed (THUNARX_RENAMER (number_renamer));
}
Beispiel #13
0
static GimpPlugInProcedure *
file_proc_find_by_extension (GSList      *procs,
                             const gchar *uri,
                             gboolean     skip_magic,
                             gboolean     uri_procs_only)
{
  GSList      *p;
  const gchar *ext;

  ext = strrchr (uri, '.');

  if (! ext)
    return NULL;

  ext++;

  for (p = procs; p; p = g_slist_next (p))
    {
      GimpPlugInProcedure *proc = p->data;
      GSList              *extensions;

      if (uri_procs_only && ! proc->handles_uri)
        continue;

      for (extensions = proc->extensions_list;
           extensions;
           extensions = g_slist_next (extensions))
        {
          const gchar *p1 = ext;
          const gchar *p2 = extensions->data;

          if (skip_magic && proc->magics_list)
            continue;

          while (*p1 && *p2)
            {
              if (g_ascii_tolower (*p1) != g_ascii_tolower (*p2))
                break;

              p1++;
              p2++;
            }

          if (!(*p1) && !(*p2))
            return proc;
        }
    }

  return NULL;
}
Beispiel #14
0
/**
 * e2k_ascii_strcase_hash
 * @v: a string
 *
 * ASCII-case-insensitive hash function for use with #GHashTable.
 *
 * Return value: An ASCII-case-insensitive hashing of @v.
 **/
guint
e2k_ascii_strcase_hash (gconstpointer v)
{
	/* case-insensitive g_str_hash */

	const unsigned char *p = v;
	guint h = g_ascii_tolower (*p);

	if (h) {
		for (p += 1; *p != '\0'; p++)
			h = (h << 5) - h + g_ascii_tolower (*p);
	}

	return h;
}
gboolean
nm_match_spec_hwaddr (const GSList *specs, const char *hwaddr)
{
	const GSList *iter;
	char *hwaddr_match, *p;

	g_return_val_if_fail (hwaddr != NULL, FALSE);

	p = hwaddr_match = g_strdup_printf ("mac:%s", hwaddr);

	while (*p) {
		*p = g_ascii_tolower (*p);
		p++;
	}

	for (iter = specs; iter; iter = g_slist_next (iter)) {
		if (!strcmp ((const char *) iter->data, hwaddr_match)) {
			g_free (hwaddr_match);
			return TRUE;
		}
	}

	g_free (hwaddr_match);
	return FALSE;
}
Beispiel #16
0
gint
peas_utils_get_loader_id (const gchar *loader)
{
  gint i;
  gsize len;
  gchar lowercase[32];

  len = strlen (loader);

  /* No loader has a name that long */
  if (len >= G_N_ELEMENTS (lowercase))
    return -1;

  for (i = 0; i < len; ++i)
    lowercase[i] = g_ascii_tolower (loader[i]);

  lowercase[len] = '\0';

  for (i = 0; i < G_N_ELEMENTS (all_plugin_loaders); ++i)
    {
      if (g_strcmp0 (lowercase, all_plugin_loaders[i]) == 0)
        return i;
    }

  return -1;
}
static nsCAutoString
MakeCaseInsensitiveShellGlob(const char* aPattern) {
  // aPattern is UTF8
  nsCAutoString result;
  unsigned int len = strlen(aPattern);

  for (unsigned int i = 0; i < len; i++) {
    if (!g_ascii_isalpha(aPattern[i])) {
      // non-ASCII characters will also trigger this path, so unicode
      // is safely handled albeit case-sensitively
      result.Append(aPattern[i]);
      continue;
    }

    // add the lowercase and uppercase version of a character to a bracket
    // match, so it matches either the lowercase or uppercase char.
    result.Append('[');
    result.Append(g_ascii_tolower(aPattern[i]));
    result.Append(g_ascii_toupper(aPattern[i]));
    result.Append(']');

  }

  return result;
}
Beispiel #18
0
/*
 * Returns the Authorization type from the headers
 * Does not modify the header hashtable.
 */
gchar *
cockpit_auth_parse_authorization_type (GHashTable *headers)
{
  gchar *line;
  gchar *type;
  gchar *next;
  gpointer key;
  gsize i;

  /* Avoid copying as it can contain passwords */
  if (!g_hash_table_lookup_extended (headers, "Authorization", &key, (gpointer *)&line))
    return NULL;

  line = str_skip (line, ' ');
  next = strchr (line, ' ');

  if (!next)
    return NULL;

  type = g_strndup (line, next - line);
  for (i = 0; type[i] != '\0'; i++)
    type[i] = g_ascii_tolower (type[i]);

  return type;
}
Beispiel #19
0
/**
 * asb_package_log_flush:
 * @pkg: A #AsbPackage
 * @error: A #GError or %NULL
 *
 * Flushes the log queue.
 *
 * Returns: %TRUE for success, %FALSE otherwise
 *
 * Since: 0.1.0
 **/
gboolean
asb_package_log_flush (AsbPackage *pkg, GError **error)
{
	AsbPackagePrivate *priv = GET_PRIVATE (pkg);
	g_autofree gchar *logfile = NULL;
	g_autofree gchar *logdir_char = NULL;

	/* needs no update */
	if (priv->log_written_len == priv->log->len)
		return TRUE;

	/* don't write if unset */
	if (asb_package_get_config (pkg, "LogDir") == NULL)
		return TRUE;

	/* overwrite old log */
	logdir_char = g_strdup_printf ("%s/%c",
				       asb_package_get_config (pkg, "LogDir"),
				       g_ascii_tolower (priv->name[0]));
	if (!asb_utils_ensure_exists (logdir_char, error))
		return FALSE;
	priv->log_written_len = priv->log->len;
	logfile = g_strdup_printf ("%s/%s.log", logdir_char, priv->name);
	return g_file_set_contents (logfile, priv->log->str, -1, error);
}
Beispiel #20
0
gchar *
mousepad_util_config_name (const gchar *name)
{
  const gchar *s;
  gchar       *config, *t;
  gboolean     upper = TRUE;

  /* allocate string */
  config = g_new (gchar, strlen (name) + 1);

  /* convert name */
  for (s = name, t = config; *s != '\0'; ++s)
    {
      if (*s == '-')
        {
          upper = TRUE;
        }
      else if (upper)
        {
          *t++ = g_ascii_toupper (*s);
          upper = FALSE;
        }
      else
        {
          *t++ = g_ascii_tolower (*s);
        }
    }

  /* zerro terminate string */
  *t = '\0';

  return config;
}
Beispiel #21
0
char* to_lower_inplace(char* str)
{
    g_assert(str != NULL);
    for (size_t i=0; i<strlen(str); i++)
        str[i] = g_ascii_tolower(str[i]);
    return str;
}
/* Process keyboard input */
static gboolean handle_keyboard (GIOChannel *source, GIOCondition cond, CustomData *data) {
  gchar *str = NULL;
  
  if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) != G_IO_STATUS_NORMAL) {
    return TRUE;
  }
  
  switch (g_ascii_tolower (str[0])) {
  case 'c':
    update_color_channel ("CONTRAST", g_ascii_isupper (str[0]), GST_COLOR_BALANCE (data->pipeline));
    break;
  case 'b':
    update_color_channel ("BRIGHTNESS", g_ascii_isupper (str[0]), GST_COLOR_BALANCE (data->pipeline));
    break;
  case 'h':
    update_color_channel ("HUE", g_ascii_isupper (str[0]), GST_COLOR_BALANCE (data->pipeline));
    break;
  case 's':
    update_color_channel ("SATURATION", g_ascii_isupper (str[0]), GST_COLOR_BALANCE (data->pipeline));
    break;
  case 'q':
    g_main_loop_quit (data->loop);
    break;
  default:
    break;
  }
  
  g_free (str);
  
  print_current_values (data->pipeline);
  
  return TRUE;
}
static char *
normalize_codeset (const char *codeset)
{
        char *normalized_codeset;
        const char *p;
        char *q;

        normalized_codeset = g_strdup (codeset);

        if (codeset != NULL) {
                for (p = codeset, q = normalized_codeset;
                     *p != '\0'; p++) {

                        if (*p == '-' || *p == '_') {
                                continue;
                        }

                        *q = g_ascii_tolower (*p);
                        q++;
                }
                *q = '\0';
        }

        return normalized_codeset;
}
Beispiel #24
0
static gchar *
gimp_file_proc_view_pattern_from_extension (const gchar *extension)
{
  gchar *pattern;
  gchar *p;
  gint   len, i;

  g_return_val_if_fail (extension != NULL, NULL);

  /* This function assumes that file extensions are 7bit ASCII.  It
   * could certainly be rewritten to handle UTF-8 if this assumption
   * turns out to be incorrect.
   */

  len = strlen (extension);

  pattern = g_new (gchar, 4 + 4 * len);

  strcpy (pattern, "*.");

  for (i = 0, p = pattern + 2; i < len; i++, p+= 4)
    {
      p[0] = '[';
      p[1] = g_ascii_tolower (extension[i]);
      p[2] = g_ascii_toupper (extension[i]);
      p[3] = ']';
    }

  *p = '\0';

  return pattern;
}
static gchar *
to_lower (gchar *str)
{
	gchar *ptr;
	for (ptr = str; *ptr; ptr++)
		*ptr = g_ascii_tolower (*ptr);
	return str;
}
Beispiel #26
0
static gboolean
gst_object_set_name_default (GstObject * object)
{
  const gchar *type_name;
  gint count;
  gchar *name;
  GQuark q;
  guint i, l;

  /* to ensure guaranteed uniqueness across threads, only one thread
   * may ever assign a name */
  G_LOCK (object_name_mutex);

  if (!object_name_counts) {
    g_datalist_init (&object_name_counts);
  }

  q = g_type_qname (G_OBJECT_TYPE (object));
  count = GPOINTER_TO_INT (g_datalist_id_get_data (&object_name_counts, q));
  g_datalist_id_set_data (&object_name_counts, q, GINT_TO_POINTER (count + 1));

  G_UNLOCK (object_name_mutex);

  /* GstFooSink -> foosink<N> */
  type_name = g_quark_to_string (q);
  if (strncmp (type_name, "Gst", 3) == 0)
    type_name += 3;
  /* give the 20th "queue" element and the first "queue2" different names */
  l = strlen (type_name);
  if (l > 0 && g_ascii_isdigit (type_name[l - 1])) {
    name = g_strdup_printf ("%s-%d", type_name, count);
  } else {
    name = g_strdup_printf ("%s%d", type_name, count);
  }

  l = strlen (name);
  for (i = 0; i < l; i++)
    name[i] = g_ascii_tolower (name[i]);

  GST_OBJECT_LOCK (object);
  if (G_UNLIKELY (object->parent != NULL))
    goto had_parent;

  g_free (object->name);
  object->name = name;

  GST_OBJECT_UNLOCK (object);

  return TRUE;

had_parent:
  {
    g_free (name);
    GST_WARNING ("parented objects can't be renamed");
    GST_OBJECT_UNLOCK (object);
    return FALSE;
  }
}
Beispiel #27
0
/* Test of haystack has the needle prefix, comparing case
 * insensitive. haystack may be UTF-8, but needle must
 * contain only ascii. */
static gboolean
has_case_prefix (const gchar *haystack, const gchar *needle)
{
  const gchar *h, *n;

  /* Eat one character at a time. */
  h = haystack;
  n = needle;

  while (*n && *h &&
	 g_ascii_tolower (*n) == g_ascii_tolower (*h))
    {
      n++;
      h++;
    }

  return *n == '\0';
}
void
translateToLowercaseForGSettings (char *name)
{
    unsigned int i;

    /* Everything must be lowercase */
    for (i = 0; i < strlen (name); ++i)
	name[i] = g_ascii_tolower (name[i]);
}
Beispiel #29
0
void load_hashtable_list( ){

		char *word = NULL, *entry_word = NULL;
	
		entry_word = gtk_entry_get_text ( mydata.input_word );	
		//	word = g_strchomp( g_strchug( g_strdown( entry_word ) ) );
		//  it has caused a Pango: index out of bound bug so use instead
		word = g_strdown( entry_word );
	
	//
		if( ! isalpha( word[0] ) ){
			//g_print("on_input_word_changed(): enter proper word\n");
			// ************** show proper warning to enter proper word *****************
//
			gtk_statusbar_pop ( mydata.statusbar, mydata.statusbar_context_id );
			gtk_statusbar_push (GTK_STATUSBAR (mydata.statusbar), mydata.statusbar_context_id, "Please enter/select proper english word");
//
			return;
		}								
		//check if hash table is created for word[0] of not
		g_sprintf( file_loaded_name, APP_DBS"%c.db", g_ascii_tolower( word[0] ) );
		//g_print("on_input_word_changed(): filename = %s\n",file_loaded_name);
		
		if( mydata.hash_tab[ g_ascii_toupper(word[0]) - 'A' ] == NULL ){
			//remove the prev word entries
			//remove_all_from_list ();
			//g_print("on_input_word_changed(): generating hash table\n");
			mydata.hash_tab[ g_ascii_toupper(word[0]) - 'A' ] = generate_hash_table( file_loaded_name );
			mydata.list_store_arr[ g_ascii_toupper(word[0]) - 'A' ] = mydata.list_store;
			list_loaded = g_ascii_toupper(word[0]) - 'A';
			//check if hash table is created or not by generate_hash_table() func call				 
			if( mydata.hash_tab[ g_ascii_toupper(word[0]) - 'A' ] == NULL ){
				g_print("on_input_word_changed():\nafter trying to generate_hash_table\nfile: %s could not be located and loaded\n", file_loaded_name );
			}						 
		}else{
			//g_print("on_input_word_changed(): %d", list_loaded );
			if( list_loaded != (g_ascii_toupper(word[0]) - 'A') ){
				//remove_all_from_list ();
//************   we have change here to fasten************ -------------->>>>>>>>>
//load list from pointer else populate it			
				if( mydata.list_store_arr[ g_ascii_toupper(word[0]) - 'A' ] == NULL ){
					populate_list_only( file_loaded_name );
					//g_print("on_input_word_changed(): list populated from file\n" );
				}else{					
					mydata.list_store = mydata.list_store_arr[ g_ascii_toupper(word[0]) - 'A' ];
//					following may be necessary		  
					gtk_tree_view_set_model ( mydata.treeview, GTK_TREE_MODEL(mydata.list_store) );
					//g_print("on_input_word_changed(): list used from previous list\n" );
				}
				
				list_loaded = (g_ascii_toupper(word[0]) - 'A');
			}
		}	
	//
	
}
Beispiel #30
0
static gboolean purple_menu_cmp(const char *a, const char *b)
{
	while (*a && *b) {
		while (*a == '_') {
			a++;
		}
		while (*b == '_') {
			b++;
		}
		if (g_ascii_tolower(*a) != g_ascii_tolower(*b)) {
			return FALSE;
		}

		a++;
		b++;
	}

	return (*a == '\0' && *b == '\0');
}