示例#1
0
static gboolean
baobab_treeview_equal_func (GtkTreeModel *model,
                            gint column,
                            const gchar *key,
                            GtkTreeIter *iter,
                            gpointer data)
{
	gboolean results = TRUE;
	gchar *name;

	gtk_tree_model_get (model, iter, 1, &name, -1);

	if (name != NULL) {
		gchar * casefold_key;
		gchar * casefold_name;

		casefold_key = g_utf8_casefold (key, -1);
		casefold_name = g_utf8_casefold (name, -1);

		if ((casefold_key != NULL) &&
		    (casefold_name != NULL) &&
		    (strstr (casefold_name, casefold_key) != NULL)) {
			results = FALSE;
		}
		g_free (casefold_key);
		g_free (casefold_name);
		g_free (name);
	}
	return results;
}
示例#2
0
static inline int
compare_string_values (const GValue *a_value, const GValue *b_value)
{
	const char *str1, *str2;
	int retval;

	str1 = g_value_get_string (a_value);
	str2 = g_value_get_string (b_value);

	if (str1 == NULL)
	{
		retval = -1;
	}
	else if (str2 == NULL)
	{
		retval = 1;
	}
	else
	{
		char *str_a;
		char *str_b;

		str_a = g_utf8_casefold (str1, -1);
		str_b = g_utf8_casefold (str2, -1);
		retval = g_utf8_collate (str_a, str_b);
		g_free (str_a);
		g_free (str_b);
	}

	return retval;
}
示例#3
0
/**
 * compare 2 chaines case-insensitive que ce soit utf8 ou ascii
 *
 *
 *
 * */
gint my_strncasecmp ( gchar *string_1,
                        gchar *string_2,
                        gint longueur )
{
    if (!string_1 && string_2)
        return 1;
    if (string_1 && !string_2)
        return -1;

    if ( string_1 && string_2 )
    {
        if ( g_utf8_validate ( string_1, -1, NULL )
             &&
             g_utf8_validate ( string_2, -1, NULL ))
        {
            gint retour;
            gchar *new_1, *new_2;

            new_1 = g_utf8_casefold ( string_1,longueur );
            new_2 = g_utf8_casefold (  string_2,longueur );
            retour = g_utf8_collate ( new_1, new_2);

            g_free ( new_1 );
            g_free ( new_2 );
            return ( retour );
        }
        else
            return ( g_ascii_strncasecmp ( string_1, string_2, longueur ) );
    }

    return 0;
}
示例#4
0
/**
 * \see find_string_in_list
 */
gchar *find_string_in_list_utf8nocase(GList *list, const gchar *string)
{
	gchar *string_casefold = g_utf8_casefold(string, -1);

	while (list)
		{
		gchar *haystack = list->data;

		if (haystack)
			{
			gboolean equal;
			gchar *haystack_casefold = g_utf8_casefold(haystack, -1);

			equal = (strcmp(haystack_casefold, string_casefold) == 0);
			g_free(haystack_casefold);

			if (equal)
				{
				g_free(string_casefold);
				return haystack;
				}
			}

		list = list->next;
		}

	g_free(string_casefold);
	return NULL;
}
示例#5
0
/** used to compare 2 iters and sort the by reconcile number first, and
 * by date and no transaction after
 * always put the white line below
 * \param model the GtkTreeModel
 * \param iter_1
 * \param iter_2
 * \return -1 if iter_1 is above iter_2
 * */
gint gsb_transactions_list_sort_by_reconcile_nb ( gint transaction_number_1,
                        gint transaction_number_2 )
{
    gint return_value;

    if ( gsb_data_transaction_get_reconcile_number ( transaction_number_1) == gsb_data_transaction_get_reconcile_number ( transaction_number_2))
		return gsb_transactions_list_sort_by_date_and_no ( transaction_number_1, transaction_number_2 );
    else
    {
	const gchar *temp_1;
	const gchar *temp_2;

	temp_1 = gsb_data_reconcile_get_name ( gsb_data_transaction_get_reconcile_number ( transaction_number_1));
	temp_2 = gsb_data_reconcile_get_name ( gsb_data_transaction_get_reconcile_number ( transaction_number_2));

	/* g_utf8_collate is said not very fast, must try with big big account to check
	 * if it's enough, for me it's ok (cedric), eventually, change with gsb_strcasecmp */
	return_value = g_utf8_collate ( g_utf8_casefold ( temp_1 ? temp_1 : "",
							  -1 ),
					g_utf8_casefold ( temp_2 ? temp_2 : "",
							  -1 ));
    }

    if ( return_value )
    	return return_value;
    else
		return gsb_transactions_list_sort_by_date_and_no ( transaction_number_1, transaction_number_2 );
}
示例#6
0
int
gth_sort_by_comment_then_name (const char *string1,
			       const char *string2,
			       const char *name1,
			       const char *name2)
{
	int collate_result;
	int name_result;

	name_result = gth_sort_by_filename_but_ignore_path (name1, name2);

	if ((string1 == NULL) && (string2 == NULL))
                return name_result;
        if (string2 == NULL)
                return 1;
        if (string1 == NULL)
                return -1;

	collate_result = g_utf8_collate ( g_utf8_casefold (string1,-1), g_utf8_casefold (string2,-1) );

	if (collate_result)
		return collate_result;
	else
		return name_result;
}
示例#7
0
/*
 * Renders an opcode.  The opcodes can take an argument by adding trailing ':'
 * to the opcode and then a number format code
 */
static void
render_opcode (GString *target, char /* non-const */ *opcode,
	       HFRenderInfo *info,
	       G_GNUC_UNUSED HFRenderType render_type)
{
	char *args;
	char *opcode_trans;
	int i;

	args = g_utf8_strchr (opcode, -1, ':');
	if (args) {
		*args = 0;
		args++;
	}
	opcode_trans = g_utf8_casefold (opcode, -1);

	for (i = 0; render_ops [i].name; i++) {
		if (render_ops [i].name_trans == NULL) {
			render_ops [i].name_trans = g_utf8_casefold (_(render_ops [i].name), -1);
		}

		if ((g_ascii_strcasecmp (render_ops [i].name, opcode) == 0) ||
		    (g_utf8_collate (render_ops [i].name_trans, opcode_trans) == 0)) {
			(*render_ops [i].render)(target, info, args);
		}
	}
	g_free (opcode_trans);
}
示例#8
0
static gboolean
testText (const tr_torrent * tor, const char * key)
{
  gboolean ret = FALSE;

  if (!key || !*key)
    {
      ret = TRUE;
    }
  else
    {
      tr_file_index_t i;
      const tr_info * inf = tr_torrentInfo (tor);

      /* test the torrent name... */
      {
        char * pch = g_utf8_casefold (tr_torrentName (tor), -1);
        ret = !key || strstr (pch, key) != NULL;
        g_free (pch);
      }

      /* test the files... */
      for (i=0; i<inf->fileCount && !ret; ++i)
        {
          char * pch = g_utf8_casefold (inf->files[i].name, -1);
          ret = !key || strstr (pch, key) != NULL;
          g_free (pch);
        }
    }

  return ret;
}
示例#9
0
/** used to compare 2 iters and sort the by category first, and
 * by date and no transaction after
 * always put the white line below
 * \param model the GtkTreeModel
 * \param iter_1
 * \param iter_2
 * \return -1 if iter_1 is above iter_2
 * */
gint gsb_transactions_list_sort_by_category ( gint transaction_number_1,
                        gint transaction_number_2 )
{
    gint return_value;
    gchar *temp_1;
    gchar *temp_2;

    /** we want to take the name of the categ, so, either
     * split of transaction
     * transfer : ...
     * categ : under-categ
     * and after, we sort by str
     * */

    temp_1 = gsb_transactions_get_category_real_name ( transaction_number_1);
    temp_2 = gsb_transactions_get_category_real_name ( transaction_number_2);

    /* g_utf8_collate is said not very fast, must try with big big account to check
     * if it's enough, for me it's ok (cedric), eventually, change with gsb_strcasecmp */
    return_value = g_utf8_collate ( g_utf8_casefold ( temp_1 ? temp_1 : "",
						      -1 ),
				    g_utf8_casefold ( temp_2 ? temp_2 : "",
						      -1 ));

    g_free (temp_1);
    g_free (temp_2);

    if ( return_value )
	    return return_value;
    else
	    return gsb_transactions_list_sort_by_date_and_no ( transaction_number_1, transaction_number_2 );
}
示例#10
0
/**
 * @brief Appends a user information message to the log window queue
 * @param data The message
 * @returns FALSE
 * 
 * If the first word of the message is either "error" or "warning"
 * (case insensitive) the message is color-coded appropriately
 */
static gboolean log_normal_cb(gpointer data)
{
	gchar *buf = data;
	gchar *buf_casefold = g_utf8_casefold(buf, -1);
	gchar *error_casefold = g_utf8_casefold(_("error"), -1);
	gchar *warning_casefold = g_utf8_casefold(_("warning"), -1);

	if (buf_casefold == g_strstr_len(buf_casefold, -1, error_casefold))
		{
		log_window_append(buf, LOG_ERROR);
		}
	else if (buf_casefold == g_strstr_len(buf_casefold, -1, warning_casefold))
		{
		log_window_append(buf, LOG_WARN);
		}
	else
		{
		log_window_append(buf, LOG_NORMAL);
		}

	g_free(buf);
	g_free(buf_casefold);
	g_free(error_casefold);
	g_free(warning_casefold);
	return FALSE;
}
示例#11
0
文件: eina-muine.c 项目: maop/eina
static void
search_changed_cb(GtkWidget *w, EinaMuine *self)
{
    EinaMuinePrivate *priv = self->priv;

    const gchar *search_str = gtk_entry_get_text(GTK_ENTRY(w));
    if (search_str && (search_str[0] == '\0'))
        search_str = NULL;

    // From no-search to search
    if ((priv->search_str == NULL) && (search_str != NULL))
    {
        priv->search_str = g_utf8_casefold(search_str, -1);
        gtk_tree_model_filter_refilter(muine_get_filter(self));
    }

    // From search to more complex search
    else if ((priv->search_str != NULL) && (search_str != NULL))
    {
        g_free(priv->search_str);
        priv->search_str = g_utf8_casefold(search_str, -1);
        gtk_tree_model_filter_refilter(muine_get_filter(self));
    }

    // From search to no search
    else if ((priv->search_str != NULL) && (search_str == NULL))
    {
        gel_free_and_invalidate(priv->search_str, NULL, g_free);
        gtk_tree_model_filter_refilter(muine_get_filter(self));
    }

    else
        g_warning(N_("Unhandled situation"));
}
示例#12
0
/**
 * compare 2 strings unsensitive
 * if a string is NULL, it will go after the non NULL
 *
 * \param string_1
 * \param string_2
 *
 * \return -1 string_1 before string_2 (or string_2 NULL) ; 0 if same or NULL everyone ; +1 if string_1 after string_2 (or string_1 NULL)
 * */
gint my_strcasecmp ( const gchar *string_1, const gchar *string_2 )
{
    if (!string_1 && string_2)
	    return 1;
    if (string_1 && !string_2)
	    return -1;

    if ( string_1  && string_2 )
    {
        if ( g_utf8_validate ( string_1, -1, NULL )
             &&
             g_utf8_validate ( string_2, -1, NULL ))
        {
            gint retour;
            gchar *new_1, *new_2;

            new_1 = g_utf8_collate_key ( g_utf8_casefold ( string_1,-1 ),
                         -1 );
            new_2 = g_utf8_collate_key ( g_utf8_casefold (  string_2,-1 ),
                         -1 );
            retour = strcmp ( new_1,
                      new_2 );
            g_free ( new_1 );
            g_free ( new_2 );
            return ( retour );
        }
        else
            return ( g_ascii_strcasecmp ( string_1, string_2 ) );
    }

    return 0;
}
示例#13
0
文件: sss_utf8.c 项目: SSSD/sssd
errno_t sss_utf8_case_eq(const uint8_t *s1, const uint8_t *s2)
{
    gchar *gs1;
    gchar *gs2;
    gssize n1, n2;
    gint gret;
    errno_t ret;

    n1 = g_utf8_strlen((const gchar *)s1, -1);
    n2 = g_utf8_strlen((const gchar *)s2, -1);

    gs1 = g_utf8_casefold((const gchar *)s1, n1);
    if (gs1 == NULL) {
        return ENOMEM;
    }

    gs2 = g_utf8_casefold((const gchar *)s2, n2);
    if (gs2 == NULL) {
        return ENOMEM;
    }

    gret = g_utf8_collate(gs1, gs2);
    if (gret == 0) {
        ret = EOK;
    } else {
        ret = ENOMATCH;
    }

    g_free(gs1);
    g_free(gs2);

    return ret;
}
static GList *
log_store_empathy_search_new (EmpathyLogStore *self,
                              const gchar *text)
{
  GList *files, *l;
  GList *hits = NULL;
  gchar *text_casefold;

  g_return_val_if_fail (EMPATHY_IS_LOG_STORE (self), NULL);
  g_return_val_if_fail (!EMP_STR_EMPTY (text), NULL);

  text_casefold = g_utf8_casefold (text, -1);

  files = log_store_empathy_get_all_files (self, NULL);
  DEBUG ("Found %d log files in total", g_list_length (files));

  for (l = files; l; l = g_list_next (l))
    {
      gchar *filename;
      GMappedFile *file;
      gsize length;
      gchar *contents;
      gchar *contents_casefold;

      filename = l->data;

      file = g_mapped_file_new (filename, FALSE, NULL);
      if (!file)
        continue;

      length = g_mapped_file_get_length (file);
      contents = g_mapped_file_get_contents (file);
      contents_casefold = g_utf8_casefold (contents, length);

      g_mapped_file_unref (file);

      if (strstr (contents_casefold, text_casefold))
        {
          EmpathyLogSearchHit *hit;

          hit = log_store_empathy_search_hit_new (self, filename);

          if (hit)
            {
              hits = g_list_prepend (hits, hit);
              DEBUG ("Found text:'%s' in file:'%s' on date:'%s'",
                  text, hit->filename, hit->date);
            }
        }

      g_free (contents_casefold);
      g_free (filename);
    }

  g_list_free (files);
  g_free (text_casefold);

  return hits;
}
static gboolean
model_filter_func (GtkTreeModel              *model,
                   GtkTreeIter               *iter,
                   GnomeControlCenterPrivate *priv)
{
  gchar *name, *description;
  gchar *needle, *haystack;
  gboolean result;
  gchar **keywords;

  gtk_tree_model_get (model, iter,
                      COL_NAME, &name,
                      COL_DESCRIPTION, &description,
                      COL_KEYWORDS, &keywords,
                      -1);

  if (!priv->filter_string || !name)
    {
      g_free (name);
      g_free (description);
      g_strfreev (keywords);
      return FALSE;
    }

  needle = g_utf8_casefold (priv->filter_string, -1);
  haystack = g_utf8_casefold (name, -1);

  result = (strstr (haystack, needle) != NULL);

  if (!result && description)
    {
      gchar *folded;

      folded = g_utf8_casefold (description, -1);
      result = (strstr (folded, needle) != NULL);
      g_free (folded);
    }

  if (!result && keywords)
    {
      gint i;
      gchar *keyword;

      for (i = 0; !result && keywords[i]; i++)
        {
          keyword = g_utf8_casefold (keywords[i], -1);
          result = strstr (keyword, needle) == keyword;
          g_free (keyword);
        }
    }

  g_free (name);
  g_free (haystack);
  g_free (needle);
  g_strfreev (keywords);

  return result;
}
示例#16
0
static int
compare_case_insensitive(const char* str1, const char* str2)
{
  char* ustr1 = g_utf8_casefold(str1, -1);
  char* ustr2 = g_utf8_casefold(str2, -1);
  int res = g_utf8_collate(ustr1, ustr2);
  g_free(ustr1);
  g_free(ustr2);
  return res;
}
示例#17
0
static gboolean
utf8_case_has_suffix (const gchar *str, const gchar *suffix)
{
	gchar *str_folded = g_utf8_casefold (str, -1);
	gchar *suffix_folded = g_utf8_casefold (suffix, -1);
	gboolean has_suffix = g_str_has_suffix (str_folded, suffix_folded);

	g_free (str_folded);
	g_free (suffix_folded);
	return has_suffix;
}
示例#18
0
static gint sort_languages(gconstpointer a, gconstpointer b)
{
  gchar *name_a = g_utf8_casefold(dt_l10n_get_name((const dt_l10n_language_t *)a), -1);
  gchar *name_b = g_utf8_casefold(dt_l10n_get_name((const dt_l10n_language_t *)b), -1);

  int result = g_strcmp0(name_a, name_b);

  g_free(name_a);
  g_free(name_b);

  return result;
}
gint util_utf8_strcasecmp(const gchar * str1, const gchar * str2)
{
	gchar * folded1 = g_utf8_casefold(str1, -1),
		* folded2 = g_utf8_casefold(str2, -1);
	gint result;

	result = g_utf8_collate(folded1, folded2);

	g_free(folded1);
	g_free(folded2);

	return result;
}
示例#20
0
gint
groups_compare (const gchar *a, const gchar *b)
{
	gint result;
	gchar *str1, *str2;

	str1 = g_utf8_casefold(a, -1);
	str2 = g_utf8_casefold(b, -1);
	result = g_utf8_collate(str1, str2);
	g_free(str1);
	g_free(str2);
	return result;
}
示例#21
0
文件: util.c 项目: PDXostc/navit
int
navit_utf8_strcasecmp(const char *s1, const char *s2)
{
        char *s1_folded,*s2_folded;
	int cmpres;
	s1_folded=g_utf8_casefold(s1,-1);
	s2_folded=g_utf8_casefold(s2,-1);
	cmpres=strcmp(s1_folded,s2_folded);
	dbg(lvl_debug,"Compared %s with %s, got %d\n",s1_folded,s2_folded,cmpres);
	g_free(s1_folded);
	g_free(s2_folded);
	return cmpres;
}
示例#22
0
static char *
str_utf8_create_key_gen (const char *text, int case_sen,
			 gchar * (*keygen) (const gchar *, gssize size))
{
    char *result;
    
    if (case_sen) {
        result = str_utf8_normalize (text);
    } else {
        const char *start, *end;
        char *fold, *key;
        GString *fixed = g_string_new ("");

        start = text;
        while (!g_utf8_validate (start, -1, &end) && start[0] != '\0')
        {
            if (start != end)
            {
                fold = g_utf8_casefold (start, end - start);
                key = keygen (fold, -1);
                g_string_append (fixed, key);
                g_free (key);
                g_free (fold);
            }
            g_string_append_c (fixed, end[0]);
            start = end + 1;
        }

        if (start == text)
        {
            fold = g_utf8_casefold (text, -1);
            result = keygen (fold, -1);
            g_free (fold);
        }
        else
        {
            if (start[0] != '\0' && start != end)
            {
                fold = g_utf8_casefold (start, end - start);
                key = keygen (fold, -1);
                g_string_append (fixed, key);
                g_free (key);
                g_free (fold);
            }
            result = g_strdup (fixed->str);
        }
        g_string_free (fixed, TRUE);
    }
    return result;
}
示例#23
0
/*! Match and possibly modify the given object's given property.
 * Returns FALSE if not matched or if the input property is NULL. */
static gboolean
_match_text_prop (DiaObject *obj, const SearchData *sd, const gchar *replacement, gchar **value_to_match)
{
  gboolean is_match = FALSE;
  gchar    *repl = NULL;

  if (!value_to_match || *value_to_match == NULL)
    return FALSE;

  /* search part */
  if (sd->flags & MATCH_CASE) {
    const gchar *p = strstr (*value_to_match, sd->key);
    is_match = p != NULL;
    if (p && replacement) {
      gchar *a = g_strndup (*value_to_match, p - *value_to_match);
      gchar *b = g_strdup (p + strlen(sd->key));
      repl = g_strdup_printf ("%s%s%s", a, replacement, b);
      g_free (a);
      g_free (b);
    }
  } else {
    gchar *s1 = g_utf8_casefold (*value_to_match, -1);
    gchar *s2 = g_utf8_casefold (sd->key, -1);
    const gchar *p = strstr (s1, s2);
    is_match = p != NULL;
    if (p && replacement) {
      gchar *a = g_strndup (*value_to_match, p - s1);
      gchar *b = g_strdup (*value_to_match + strlen(a) + strlen(sd->key));
      repl = g_strdup_printf ("%s%s%s", a, replacement, b);
      g_free (a);
      g_free (b);
    }
    g_free (s1);
    g_free (s2);
  }

  if (sd->flags & MATCH_WORD)
    is_match = (is_match && strlen(*value_to_match) == strlen(sd->key));

  /* replace part */
  if (is_match && replacement) {
    g_free (*value_to_match);
    *value_to_match = repl;
  } else {
    g_free (repl);
  }
  
  return is_match;
}
示例#24
0
static gint
key_score (const gchar *key_,
           const gchar *text_)
{
  gchar  *text  = g_utf8_casefold (text_, -1);
  gchar  *key   = g_utf8_casefold (key_, -1);
  gint    score;
  
  score = get_score (key, text) + get_score (key, path_basename (text)) / 2;
  
  g_free (text);
  g_free (key);
  
  return score;
}
示例#25
0
文件: strutilutf8.c 项目: LubkaB/mc
static char *
str_utf8_casefold_normalize (const char *text)
{
    GString *fixed;
    char *tmp, *fold;
    char *result;
    const char *start;
    const char *end;

    fixed = g_string_sized_new (4);

    start = text;
    while (!g_utf8_validate (start, -1, &end) && start[0] != '\0')
    {
        if (start != end)
        {
            fold = g_utf8_casefold (start, end - start);
            tmp = g_utf8_normalize (fold, -1, G_NORMALIZE_ALL);
            g_string_append (fixed, tmp);
            g_free (tmp);
            g_free (fold);
        }
        g_string_append_c (fixed, end[0]);
        start = end + 1;
    }

    if (start == text)
    {
        fold = g_utf8_casefold (text, -1);
        result = g_utf8_normalize (fold, -1, G_NORMALIZE_ALL);
        g_free (fold);
        g_string_free (fixed, TRUE);
    }
    else
    {
        if (start[0] != '\0' && start != end)
        {
            fold = g_utf8_casefold (start, end - start);
            tmp = g_utf8_normalize (fold, -1, G_NORMALIZE_ALL);
            g_string_append (fixed, tmp);
            g_free (tmp);
            g_free (fold);
        }
        result = g_string_free (fixed, FALSE);
    }

    return result;
}
示例#26
0
static Enumerator *
enumerator_new (GFile      *root,
                const char *path,
                gboolean    ignore_case)
{
  Enumerator *e;
  gint i;
  gchar *case_folded;

  e = g_new0 (Enumerator, 1);
  e->path = g_strdup (path);
  e->ignore_case = ignore_case;

  e->components = g_strsplit (e->path, G_DIR_SEPARATOR_S, -1);
  e->depth = g_strv_length (e->components);
  if (e->ignore_case)
    {
      e->case_components = g_new0 (char *, e->depth + 1);
      for (i = 0; e->components[i]; i++)
        {
          case_folded = g_utf8_casefold (e->components[i], -1);
          e->case_components[i] = g_utf8_collate_key (case_folded, -1);
          g_free (case_folded);
        }
    }
static void
seahorse_keyserver_results_set_property (GObject *obj, guint prop_id, const GValue *value, 
                           GParamSpec *pspec)
{
	SeahorseKeyserverResults *self = SEAHORSE_KEYSERVER_RESULTS (obj);
	const gchar* str;
	
	switch (prop_id) {
	case PROP_SEARCH:
		/* Many key servers ignore spaces at the beginning and end, so we do too */
		str = g_value_get_string (value);
		if (!str)
			str = "";
		self->pv->search_string = g_strstrip (g_utf8_casefold (str, -1));
		break;
		
	case PROP_SELECTED:
		seahorse_viewer_set_selected (SEAHORSE_VIEWER (self), g_value_get_object (value));
		break;

	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
		break;
	}
}
示例#28
0
PRIVATE
GList* _get_x_category(GDesktopAppInfo* info)
{
    GList* categories = NULL;
    const char* all_categories = g_desktop_app_info_get_categories(info);
    if (all_categories == NULL) {
        categories = g_list_append(categories, GINT_TO_POINTER(OTHER_CATEGORY_ID));
        return categories;
    }

    g_debug("[%s] %s", __func__, g_desktop_app_info_get_filename(info));
    gboolean has_other_id = FALSE;
    gchar** x_categories = g_strsplit(all_categories, ";", 0);
    for (int i = 0; x_categories[i] != NULL && x_categories[i][0] != '\0'; ++i) {
        char* lower_case = g_utf8_casefold(x_categories[i], -1);
        int id = find_category_id(lower_case);
        g_free(lower_case);
        g_debug("[%s] #%s#:category name:#%s#:%d", __func__, x_categories[i], lower_case, id);
        if (id == OTHER_CATEGORY_ID)
            has_other_id = TRUE;
        categories = g_list_append(categories, GINT_TO_POINTER(id));
    }

    if (has_other_id)
        categories = _remove_other_category(categories);

    if (categories == NULL)
        categories = g_list_append(categories, GINT_TO_POINTER(OTHER_CATEGORY_ID));

    for (GList* iter = g_list_first(categories); iter != NULL; iter = g_list_next(iter))
        g_debug("[%s] using %d", __func__, GPOINTER_TO_INT(iter->data));
    g_strfreev(x_categories);
    return categories;
}
示例#29
0
gboolean
giggle_searchable_search (GiggleSearchable      *searchable,
			  const gchar           *search_term,
			  GiggleSearchDirection  direction,
			  gboolean               full_search)
{
	GiggleSearchableIface *iface;
	gboolean result = FALSE;

	g_return_val_if_fail (GIGGLE_IS_SEARCHABLE (searchable), FALSE);
	g_return_val_if_fail (direction == GIGGLE_SEARCH_DIRECTION_NEXT ||
			      direction == GIGGLE_SEARCH_DIRECTION_PREV, FALSE);

	iface = GIGGLE_SEARCHABLE_GET_IFACE (searchable);

	if (iface->search) {
		gchar *casefold_search_term;

		casefold_search_term = g_utf8_casefold (search_term, -1);
		result = (* iface->search) (searchable, casefold_search_term,
					    direction, full_search);

		g_free (casefold_search_term);
	}

	return result;
}
示例#30
0
gboolean keyword_tree_is_set(GtkTreeModel *keyword_tree, GtkTreeIter *iter, GList *kw_list)
{
	gboolean ret;
	GList *casefold_list = NULL;
	GList *work;

	if (options->metadata.keywords_case_sensitive)
		{
		ret = keyword_tree_is_set_casefull(keyword_tree, *iter, kw_list);
		}
	else
		{
		work = kw_list;
		while (work)
			{
			const gchar *kw = work->data;
			work = work->next;

			casefold_list = g_list_prepend(casefold_list, g_utf8_casefold(kw, -1));
			}

		ret = keyword_tree_is_set_casefold(keyword_tree, *iter, casefold_list);

		string_list_free(casefold_list);
		}

	return ret;
}