/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 2003-2004 Hiroyuki Yamamoto & the Sylpheed-Claws team
+ * Copyright (C) 2003-2007 Hiroyuki Yamamoto & the Claws Mail team
*
* 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
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
*/
#ifdef HAVE_CONFIG_H
static void prefs_themes_btn_use_clicked_cb (GtkWidget *widget, gpointer data);
static void prefs_themes_btn_remove_clicked_cb (GtkWidget *widget, gpointer data);
static void prefs_themes_btn_install_clicked_cb (GtkWidget *widget, gpointer data);
-static void prefs_themes_btn_more_clicked_cb (GtkWidget *widget, gpointer data);
static void prefs_themes_menu_item_activated_cb (GtkWidget *widget, gpointer data);
static void prefs_themes_update_buttons (const ThemesData *tdata);
base = g_path_get_basename(filename);
if (TRUE == is_dir_exist(filename)) {
- if (!((base[0] == '.') || (base[0] == '.' && base[1] == '.')))
- g_warning("prefs_themes_file_remove(): subdir in theme dir skipped.\n");
+ if (strcmp(base, ".") != 0 && strcmp(base, "..") != 0)
+ g_warning("prefs_themes_file_remove(): subdir in theme dir skipped: '%s'.\n",
+ base);
}
else if (0 != g_unlink(filename)) {
(*status) = g_strdup(filename);
base = g_path_get_basename(filename);
if (TRUE == is_dir_exist(filename)) {
- if (!((base[0] == '.') || (base[0] == '.' && base[1] == '.')))
- g_warning("prefs_themes_file_install(): subdir in theme dir skipped.\n");
+ if (strcmp(base, ".") != 0 && strcmp(base, "..") !=0 )
+ g_warning("prefs_themes_file_install(): subdir in theme dir skipped: '%s'.\n",
+ base);
}
else {
gchar *fulldest;
(*func)(fullentry, data);
g_free(fullentry);
- }
+ }
+ closedir(dp);
}
static gboolean prefs_themes_is_system_theme(const gchar *dirname)
path[1] = _("Themes");
path[2] = NULL;
- debug_print("Creating prefereces for themes...\n");
+ debug_print("Creating preferences for themes...\n");
tdata = g_new0(ThemesData, 1);
prefs_themes_data = tdata;
{
ThemesData *tdata = prefs_themes_data;
- debug_print("Finished prefereces for themes.\n");
+ debug_print("Finished preferences for themes.\n");
stock_pixmap_themes_list_free(tdata->themes);
prefs_themes_free_names(tdata);
theme_str = tdata->displayed;
- if (prefs_common.pixmap_theme_path != NULL)
g_free(prefs_common.pixmap_theme_path);
prefs_common.pixmap_theme_path = g_strdup(theme_str);
tmp = g_path_get_basename(theme_str);
if (IS_SYSTEM_THEME(theme_str)) {
- if (getuid() != 0) {
+ if (!superuser_p()) {
alertpanel_error(_("Only root can remove system themes"));
return;
}
val = alertpanel(alert_title,
_("Are you sure you want to remove this theme?"),
- GTK_STOCK_YES, GTK_STOCK_NO, NULL);
+ GTK_STOCK_NO, GTK_STOCK_YES, NULL);
g_free(alert_title);
- if (G_ALERTDEFAULT == val) {
+ if (G_ALERTALTERNATE == val) {
gchar *status = NULL;
prefs_themes_foreach_file(theme_str, prefs_themes_file_remove, &status);
if (file_exist(themeinfo, FALSE) == FALSE) {
val = alertpanel(alert_title,
_("This folder doesn't seem to be a theme folder.\nInstall anyway?"),
- GTK_STOCK_YES, GTK_STOCK_NO, NULL);
- if (G_ALERTDEFAULT != val)
+ GTK_STOCK_NO, GTK_STOCK_YES, NULL);
+ if (G_ALERTALTERNATE != val)
goto end_inst;
}
- if (getuid() == 0) {
+ if (superuser_p ()) {
val = alertpanel(alert_title,
_("Do you want to install theme for all users?"),
- GTK_STOCK_YES, GTK_STOCK_NO, NULL);
+ GTK_STOCK_NO, GTK_STOCK_YES, NULL);
switch (val) {
- case G_ALERTDEFAULT:
+ case G_ALERTALTERNATE:
cinfo->dest = g_strconcat(PACKAGE_DATA_DIR, G_DIR_SEPARATOR_S,
PIXMAP_THEME_DIR, G_DIR_SEPARATOR_S,
themename, NULL);
break;
- case G_ALERTALTERNATE:
+ case G_ALERTDEFAULT:
break;
default:
goto end_inst;
}
g_free(alert_title);
if (cinfo->dest == NULL) {
- cinfo->dest = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, RC_DIR,
+ cinfo->dest = g_strconcat(get_home_dir(), G_DIR_SEPARATOR_S, get_rc_dir(),
G_DIR_SEPARATOR_S, PIXMAP_THEME_DIR, G_DIR_SEPARATOR_S,
themename, NULL);
}
else
alertpanel_error(_("File %s failed\nwhile installing theme."), cinfo->status);
end_inst:
- if (cinfo->dest != NULL) g_free(cinfo->dest);
+ g_free(cinfo->dest);
g_free(filename);
g_free(source);
g_free(themeinfo);
g_free(themename);
}
-static void prefs_themes_btn_more_clicked_cb(GtkWidget *widget, gpointer data)
-{
- open_uri(THEMES_URI, prefs_common.uri_cmd);
-}
-
static void prefs_themes_menu_item_activated_cb(GtkWidget *widget, gpointer data)
{
ThemesData *tdata = prefs_themes_data;
if (IS_INTERNAL_THEME(path)) {
info->name = g_strdup(_("Default internal theme"));
- info->author = g_strdup(_("The Sylpheed-Claws Team"));
+ info->author = g_strdup(_("The Claws Mail Team"));
info->url = g_strdup(HOMEPAGE_URI);
info->status = g_strdup_printf(_("Internal theme has %d icons"), N_STOCK_PIXMAPS);
}
info->status = prefs_themes_get_theme_stats(path);
if (info->status == NULL) {
- info->status = g_strdup(_("Error: can't get theme status"));
+ info->status = g_strdup(_("Error: couldn't get theme status"));
}
}
{
ThemesPage *prefs_themes = (ThemesPage *)page;
ThemesData *tdata = prefs_themes_data;
- gchar *buf;
- const gchar *tmp;
- gint i;
- /* from gtk/about.c */
- GtkStyle *style;
- GdkColormap *cmap;
- GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
- gboolean success[2];
GtkWidget *vbox1;
GtkWidget *frame1;
GtkWidget *btn_use;
GtkWidget *btn_remove;
- vbox1 = gtk_vbox_new (FALSE, 0);
+ vbox1 = gtk_vbox_new (FALSE, VSPACING);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox1), VBOX_BORDER);
gtk_widget_show (vbox1);
- PACK_FRAME (vbox1, frame1, _("Selector"));
+ vbox2 = gtkut_get_options_frame(vbox1, &frame1, _("Selector"));
- vbox2 = gtk_vbox_new (FALSE, 0);
- gtk_widget_show (vbox2);
- gtk_container_add (GTK_CONTAINER (frame1), vbox2);
-
- hbox3 = gtk_hbox_new (FALSE, 0);
+ hbox3 = gtk_hbox_new (FALSE, 5);
gtk_widget_show (hbox3);
gtk_box_pack_start (GTK_BOX (vbox2), hbox3, FALSE, FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (hbox3), 5);
gtk_box_pack_start (GTK_BOX (hbox3), btn_install, FALSE, FALSE, 0);
GTK_WIDGET_SET_FLAGS (btn_install, GTK_CAN_DEFAULT);
- btn_more = gtk_button_new_with_label (_("Get more..."));
+ btn_more = gtkut_get_link_btn((GtkWidget *)window, THEMES_URI, _("Get more..."));
gtk_widget_show (btn_more);
gtk_box_pack_start (GTK_BOX (hbox3), btn_more, FALSE, FALSE, 0);
- GTK_WIDGET_SET_FLAGS (btn_more, GTK_CAN_DEFAULT);
- /* make it look like an uri */
- gtk_button_set_relief(GTK_BUTTON(btn_more), GTK_RELIEF_NONE);
- tmp = gtk_label_get_text(GTK_LABEL(GTK_BIN(btn_more)->child));
- buf = g_strdup(tmp);
- for (i = 0; buf[i] != '\0'; buf[i++] = '_');
- gtk_label_set_pattern(GTK_LABEL(GTK_BIN(btn_more)->child), buf);
- g_free(buf);
- cmap = gdk_drawable_get_colormap((mainwindow_get_mainwindow())->window->window);
- gdk_colormap_alloc_colors(cmap, uri_color, 2, FALSE, TRUE, success);
- if (success[0] == TRUE && success[1] == TRUE) {
- gtk_widget_ensure_style(GTK_BIN(btn_more)->child);
- style = gtk_style_copy
- (gtk_widget_get_style(GTK_BIN(btn_more)->child));
- style->fg[GTK_STATE_NORMAL] = uri_color[0];
- style->fg[GTK_STATE_ACTIVE] = uri_color[1];
- style->fg[GTK_STATE_PRELIGHT] = uri_color[0];
- gtk_widget_set_style(GTK_BIN(btn_more)->child, style);
- } else
- g_warning("prefs_themes_create_widget(): color allocation failed.\n");
-
label_global_status = gtk_label_new ("");
gtk_widget_show (label_global_status);
gtk_container_add (GTK_CONTAINER (frame_buttons), hbuttonbox1);
gtk_container_set_border_width (GTK_CONTAINER (hbuttonbox1), 5);
gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox1), GTK_BUTTONBOX_START);
- gtk_button_box_set_spacing (GTK_BUTTON_BOX (hbuttonbox1), 5);
- gtk_button_box_set_child_ipadding (GTK_BUTTON_BOX (hbuttonbox1), 5, 0);
+ gtk_box_set_spacing (GTK_BOX (hbuttonbox1), 5);
btn_use = gtk_button_new_with_label (_("Use this"));
gtk_widget_show (btn_use);
g_signal_connect(G_OBJECT(btn_install), "clicked",
G_CALLBACK(prefs_themes_btn_install_clicked_cb),
NULL);
- g_signal_connect(G_OBJECT(btn_more), "clicked",
- G_CALLBACK(prefs_themes_btn_more_clicked_cb),
- NULL);
prefs_themes->window = GTK_WIDGET(window);