gee
oldstatus
2005-09-19, Nathan Walp
* Gaim is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "conversation.h" struct smiley_list *next; GSList *smiley_themes = NULL; struct smiley_theme *current_smiley_theme; void smiley_themeize(GtkWidget *imhtml) struct smiley_list *list; if (!current_smiley_theme) gtk_imhtml_remove_smileys(GTK_IMHTML(imhtml)); list = current_smiley_theme->list; char *sml = !strcmp(list->sml, "default") ? NULL : list->sml; GSList *icons = list->smileys; gtk_imhtml_associate_smiley(GTK_IMHTML(imhtml), sml, icons->data); void load_smiley_theme(const char *file, gboolean load) FILE *f = g_fopen(file, "r"); struct smiley_theme *theme=NULL; struct smiley_list *list = NULL; GSList *lst = smiley_themes; struct smiley_theme *thm = lst->data; if (!strcmp(thm->path, file)) { theme = g_new0(struct smiley_theme, 1); theme->path = g_strdup(file); smiley_themes = g_slist_append(smiley_themes, theme); dirname = g_path_get_dirname(file); if (current_smiley_theme) { GSList *already_freed = NULL; struct smiley_list *wer = current_smiley_theme->list, *wer2; GtkIMHtmlSmiley *uio = wer->smileys->data; g_object_unref(uio->icon); if (!g_slist_find(already_freed, uio->file)) { already_freed = g_slist_append(already_freed, uio->file); wer->smileys=g_slist_remove(wer->smileys, uio); current_smiley_theme->list = NULL; g_slist_free(already_freed); current_smiley_theme = theme; if (!fgets(buf, sizeof(buf), f)) { if (buf[0] == '#' || buf[0] == '\0') if (*i == '[' && strchr(i, ']') && load) { struct smiley_list *child = g_new0(struct smiley_list, 1); child->sml = g_strndup(i+1, strchr(i, ']') - i - 1); } else if (!g_ascii_strncasecmp(i, "Name=", strlen("Name="))) { theme->name = g_strdup(i+ strlen("Name=")); theme->name[strlen(theme->name)-1] = 0; } else if (!g_ascii_strncasecmp(i, "Description=", strlen("Description="))) { theme->desc = g_strdup(i + strlen("Description=")); theme->desc[strlen(theme->desc)-1] = 0; } else if (!g_ascii_strncasecmp(i, "Icon=", strlen("Icon="))) { theme->icon = g_build_filename(dirname, i + strlen("Icon="), NULL); theme->icon[strlen(theme->icon)-1] = 0; } else if (!g_ascii_strncasecmp(i, "Author=", strlen("Author="))) { theme->author = g_strdup(i + strlen("Author=")); theme->author[strlen(theme->author)-1] = 0; } else if (load && list) { if (*i == '!' && *(i + 1) == ' ') { sfile = g_build_filename(dirname, l, NULL); GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1); smiley->smile = g_strdup(l); list->smileys = g_slist_append(list->smileys, smiley); for (cnv = gaim_get_conversations(); cnv != NULL; cnv = cnv->next) { GaimConversation *conv = cnv->data; if (GAIM_IS_GTK_CONVERSATION(conv)) { smiley_themeize(GAIM_GTK_CONVERSATION(conv)->imhtml); smiley_themeize(GAIM_GTK_CONVERSATION(conv)->entry); void smiley_theme_probe() probedirs[0] = g_build_filename(DATADIR, "pixmaps", "gaim", "smileys", NULL); probedirs[1] = g_build_filename(gaim_user_dir(), "smileys", NULL); for (l=0; probedirs[l]; l++) { dir = g_dir_open(probedirs[l], 0, NULL); while ((file = g_dir_read_name(dir))) { path = g_build_filename(probedirs[l], file, "theme", NULL); /* Here we check to see that the theme has proper syntax. * We set the second argument to FALSE so that it doesn't load load_smiley_theme(path, FALSE); g_mkdir(probedirs[l], S_IRUSR | S_IWUSR | S_IXUSR); GSList *get_proto_smileys(const char *id) { GaimPlugin *proto = gaim_find_prpl(id); struct smiley_list *list, *def; if(!current_smiley_theme) if(!current_smiley_theme->list) def = list = current_smiley_theme->list; if(!strcmp(list->sml, "default")) else if(proto && !strcmp(proto->info->name, list->sml)) return list ? list->smileys : def->smileys;