Compare commits

..

No commits in common. "master" and "khorben/gtkdoc" have entirely different histories.

4 changed files with 35 additions and 68 deletions

View File

@ -1,4 +1,3 @@
../src/account.c
../src/common.c ../src/common.c
../src/compose.c ../src/compose.c
../src/compose-main.c ../src/compose-main.c

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2006-2024 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2006-2018 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Mailer */ /* This file is part of DeforaOS Desktop Mailer */
/* All rights reserved. /* All rights reserved.
* *
@ -33,7 +33,6 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <libintl.h>
#include <System.h> #include <System.h>
#include "folder.h" #include "folder.h"
#include "mailer.h" #include "mailer.h"
@ -41,8 +40,6 @@
#include "account.h" #include "account.h"
#include "../config.h" #include "../config.h"
#define _(string) gettext(string)
/* constants */ /* constants */
#ifndef PREFIX #ifndef PREFIX
@ -154,7 +151,7 @@ Account * account_new(Mailer * mailer, char const * type, char const * title,
|| account->definition->get_config == NULL) || account->definition->get_config == NULL)
{ {
account_delete(account); account_delete(account);
error_set_code(1, "%s%s", _("Invalid plug-in "), type); error_set_code(1, "%s%s", "Invalid plug-in ", type);
return NULL; return NULL;
} }
if(store != NULL) if(store != NULL)
@ -544,7 +541,7 @@ static void _helper_event_status(Account * account, AccountEvent * event)
switch(event->status.status) switch(event->status.status)
{ {
case AS_IDLE: case AS_IDLE:
message = _("Ready"); message = "Ready";
break; break;
default: default:
break; break;
@ -565,8 +562,8 @@ static char * _account_helper_authenticate(Account * account,
GtkWidget * widget; GtkWidget * widget;
dialog = gtk_dialog_new(); dialog = gtk_dialog_new();
/* XXX enumerate the methods available */ /* XXX translate this, enumerate the methods available */
gtk_window_set_title(GTK_WINDOW(dialog), _("Authentication")); gtk_window_set_title(GTK_WINDOW(dialog), "Authentication");
#if GTK_CHECK_VERSION(2, 14, 0) #if GTK_CHECK_VERSION(2, 14, 0)
vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
#else #else
@ -598,11 +595,12 @@ static int _account_helper_confirm(Account * account, char const * message)
dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_QUESTION, dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO, GTK_BUTTONS_YES_NO,
#if GTK_CHECK_VERSION(2, 6, 0) #if GTK_CHECK_VERSION(2, 6, 0)
"%s", _("Confirm")); "%s", "Confirm");
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog), gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
#endif #endif
"%s", message); "%s", message);
gtk_window_set_title(GTK_WINDOW(dialog), _("Confirm")); /* XXX translate this */
gtk_window_set_title(GTK_WINDOW(dialog), "Confirm");
ret = (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES) ? 0 : 1; ret = (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_YES) ? 0 : 1;
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
return ret; return ret;

View File

@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
/* Copyright (c) 2006-2024 Pierre Pronchery <khorben@defora.org> */ /* Copyright (c) 2006-2020 Pierre Pronchery <khorben@defora.org> */
/* This file is part of DeforaOS Desktop Mailer */ /* This file is part of DeforaOS Desktop Mailer */
/* All rights reserved. /* All rights reserved.
* *
@ -47,16 +47,12 @@
#include "callbacks.h" #include "callbacks.h"
#include "mailer.h" #include "mailer.h"
#include "../config.h" #include "../config.h"
#define _(string) gettext(string) #define _(string) gettext(string)
#define N_(string) (string) #define N_(string) (string)
#include "common.c" #include "common.c"
/* constants */ /* constants */
#ifndef PROGNAME_MAILER
# define PROGNAME_MAILER "mailer"
#endif
#ifndef PREFIX #ifndef PREFIX
# define PREFIX "/usr/local" # define PREFIX "/usr/local"
#endif #endif
@ -74,15 +70,6 @@
/* Mailer */ /* Mailer */
/* private */ /* private */
/* types */ /* types */
typedef enum _AccountAssistantPage
{
AAP_INTRO = 0,
AAP_SETTINGS,
AAP_CONFIRM
} AccountAssistantPage;
#define AAP_LAST AAP_CONFIRM
#define AAP_COUNT (AAP_LAST + 1)
typedef enum _MailerPluginColumn typedef enum _MailerPluginColumn
{ {
MPC_NAME = 0, MPC_NAME = 0,
@ -165,7 +152,7 @@ typedef void (*MailerForeachMessageCallback)(Mailer * mailer,
/* constants */ /* constants */
static const char * _title[AAP_COUNT] = static const char * _title[3] =
{ {
N_("New account"), N_("Account settings"), N_("Account confirmation") N_("New account"), N_("Account settings"), N_("Account confirmation")
}; };
@ -386,7 +373,7 @@ Mailer * mailer_new(void)
if((mailer = object_new(sizeof(*mailer))) == NULL) if((mailer = object_new(sizeof(*mailer))) == NULL)
{ {
error_print(PROGNAME_MAILER); error_print("mailer");
return NULL; return NULL;
} }
/* accounts */ /* accounts */
@ -649,7 +636,7 @@ static int _new_accounts(Mailer * mailer)
{ {
error_set_code(1, "%s: %s", dirname, strerror(errno)); error_set_code(1, "%s: %s", dirname, strerror(errno));
string_delete(dirname); string_delete(dirname);
return error_print(PROGNAME_MAILER); return error_print("mailer");
} }
for(de = readdir(dir); de != NULL; de = readdir(dir)) for(de = readdir(dir); de != NULL; de = readdir(dir))
{ {
@ -661,22 +648,21 @@ static int _new_accounts(Mailer * mailer)
if((p = realloc(mailer->available, (mailer->available_cnt + 1) if((p = realloc(mailer->available, (mailer->available_cnt + 1)
* sizeof(*p))) == NULL) * sizeof(*p))) == NULL)
{ {
error_set_print(PROGNAME_MAILER, 1, "%s", error_set_print("mailer", 1, "%s", strerror(errno));
strerror(errno));
continue; continue;
} }
mailer->available = p; mailer->available = p;
if((p[mailer->available_cnt] = account_new(NULL, de->d_name, if((p[mailer->available_cnt] = account_new(NULL, de->d_name,
NULL, NULL)) == NULL) NULL, NULL)) == NULL)
{ {
error_print(PROGNAME_MAILER); error_print("mailer");
continue; continue;
} }
mailer->available_cnt++; mailer->available_cnt++;
} }
if(closedir(dir) != 0) if(closedir(dir) != 0)
ret = error_set_print(PROGNAME_MAILER, 1, "%s: %s", dirname, ret = error_set_print("mailer", 1, "%s: %s", dirname, strerror(
strerror(errno)); errno));
string_delete(dirname); string_delete(dirname);
return ret; return ret;
} }
@ -1128,7 +1114,7 @@ int mailer_error(Mailer * mailer, char const * message, int ret)
#endif #endif
if(mailer == NULL) if(mailer == NULL)
return error_set_print(PROGNAME_MAILER, ret, "%s", message); return error_set_print("mailer", ret, "%s", message);
#if GTK_CHECK_VERSION(2, 18, 0) #if GTK_CHECK_VERSION(2, 18, 0)
/* info bar */ /* info bar */
gtk_label_set_text(GTK_LABEL(mailer->fo_infobar_label), message); gtk_label_set_text(GTK_LABEL(mailer->fo_infobar_label), message);
@ -2159,7 +2145,7 @@ static void _on_preferences_account_new(gpointer data)
/* plug-in selection */ /* plug-in selection */
page = _assistant_account_select(ad); page = _assistant_account_select(ad);
gtk_assistant_append_page(assistant, page); gtk_assistant_append_page(assistant, page);
gtk_assistant_set_page_title(assistant, page, _(_title[AAP_INTRO])); gtk_assistant_set_page_title(assistant, page, _(_title[0]));
gtk_assistant_set_page_type(assistant, page, GTK_ASSISTANT_PAGE_INTRO); gtk_assistant_set_page_type(assistant, page, GTK_ASSISTANT_PAGE_INTRO);
gtk_assistant_set_page_complete(assistant, page, FALSE); gtk_assistant_set_page_complete(assistant, page, FALSE);
/* plug-in preferences */ /* plug-in preferences */
@ -2168,7 +2154,7 @@ static void _on_preferences_account_new(gpointer data)
ad->settings = page; ad->settings = page;
gtk_widget_show(page); gtk_widget_show(page);
gtk_assistant_append_page(assistant, page); gtk_assistant_append_page(assistant, page);
gtk_assistant_set_page_title(assistant, page, _(_title[AAP_SETTINGS])); gtk_assistant_set_page_title(assistant, page, _(_title[1]));
gtk_assistant_set_page_type(assistant, page, gtk_assistant_set_page_type(assistant, page,
GTK_ASSISTANT_PAGE_CONTENT); GTK_ASSISTANT_PAGE_CONTENT);
gtk_assistant_set_page_complete(assistant, page, TRUE); gtk_assistant_set_page_complete(assistant, page, TRUE);
@ -2177,7 +2163,7 @@ static void _on_preferences_account_new(gpointer data)
ad->confirm = page; ad->confirm = page;
gtk_widget_show(page); gtk_widget_show(page);
gtk_assistant_append_page(assistant, page); gtk_assistant_append_page(assistant, page);
gtk_assistant_set_page_title(assistant, page, _(_title[AAP_CONFIRM])); gtk_assistant_set_page_title(assistant, page, _(_title[2]));
gtk_assistant_set_page_type(assistant, page, gtk_assistant_set_page_type(assistant, page,
GTK_ASSISTANT_PAGE_CONFIRM); GTK_ASSISTANT_PAGE_CONFIRM);
gtk_assistant_set_page_complete(assistant, page, TRUE); gtk_assistant_set_page_complete(assistant, page, TRUE);
@ -2230,17 +2216,17 @@ static GtkWidget * _account_display(Account * account);
static void _on_assistant_prepare(GtkWidget * widget, GtkWidget * page, static void _on_assistant_prepare(GtkWidget * widget, GtkWidget * page,
gpointer data) gpointer data)
{ {
static int old = AAP_INTRO; static int old = 0;
AccountData * ad = data; AccountData * ad = data;
unsigned int i; unsigned int i;
Account * ac; Account * ac;
i = gtk_assistant_get_current_page(GTK_ASSISTANT(widget)); i = gtk_assistant_get_current_page(GTK_ASSISTANT(widget));
gtk_window_set_title(GTK_WINDOW(widget), _(_title[i])); gtk_window_set_title(GTK_WINDOW(widget), _(_title[i]));
if(i == AAP_SETTINGS) if(i == 1)
{ {
gtk_container_remove(GTK_CONTAINER(page), ad->settings); gtk_container_remove(GTK_CONTAINER(page), ad->settings);
if(old == AAP_INTRO) if(old == 0)
{ {
if(ad->account != NULL) if(ad->account != NULL)
account_delete(ad->account); account_delete(ad->account);
@ -2252,7 +2238,7 @@ static void _on_assistant_prepare(GtkWidget * widget, GtkWidget * page,
{ {
mailer_error(ad->mailer, error_get(NULL), 0); mailer_error(ad->mailer, error_get(NULL), 0);
gtk_assistant_set_current_page(GTK_ASSISTANT(widget), gtk_assistant_set_current_page(GTK_ASSISTANT(widget),
AAP_INTRO); 0);
ad->settings = _assistant_account_select(ad); ad->settings = _assistant_account_select(ad);
} }
else else
@ -2261,7 +2247,7 @@ static void _on_assistant_prepare(GtkWidget * widget, GtkWidget * page,
gtk_container_add(GTK_CONTAINER(page), ad->settings); gtk_container_add(GTK_CONTAINER(page), ad->settings);
gtk_widget_show_all(ad->settings); gtk_widget_show_all(ad->settings);
} }
else if(i == AAP_CONFIRM) else if(i == 2)
{ {
gtk_container_remove(GTK_CONTAINER(page), ad->confirm); gtk_container_remove(GTK_CONTAINER(page), ad->confirm);
ad->confirm = _account_display(ad->account); ad->confirm = _account_display(ad->account);
@ -2344,32 +2330,13 @@ static void _on_account_name_changed(GtkWidget * widget, gpointer data)
AccountData * ad = data; AccountData * ad = data;
int current; int current;
GtkWidget * page; GtkWidget * page;
gboolean complete;
unsigned int i;
_on_entry_changed(widget, &ad->title); _on_entry_changed(widget, &ad->title);
current = gtk_assistant_get_current_page(GTK_ASSISTANT(ad->assistant)); current = gtk_assistant_get_current_page(GTK_ASSISTANT(ad->assistant));
page = gtk_assistant_get_nth_page(GTK_ASSISTANT(ad->assistant), page = gtk_assistant_get_nth_page(GTK_ASSISTANT(ad->assistant),
current); current);
if((complete = (strlen(ad->title) > 0) ? TRUE : FALSE) == TRUE)
for(i = 0; i < ad->mailer->account_cnt; i++)
if(strcmp(account_get_title(ad->mailer->account[i]),
ad->title) == 0)
{
complete = FALSE;
break;
}
#if GTK_CHECK_VERSION(2, 16, 0)
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(widget),
GTK_ENTRY_ICON_SECONDARY,
(strlen(ad->title) > 0 && complete == FALSE)
? "gtk-dialog-warning" : NULL);
gtk_entry_set_icon_tooltip_text(GTK_ENTRY(widget),
GTK_ENTRY_ICON_SECONDARY,
_("An account with that name already exists"));
#endif
gtk_assistant_set_page_complete(GTK_ASSISTANT(ad->assistant), page, gtk_assistant_set_page_complete(GTK_ASSISTANT(ad->assistant), page,
complete); strlen(ad->title) ? TRUE : FALSE);
} }
static void _account_add_label(GtkWidget * box, PangoFontDescription * desc, static void _account_add_label(GtkWidget * box, PangoFontDescription * desc,
@ -3010,6 +2977,7 @@ static int _preferences_ok_accounts(Mailer * mailer)
{ {
GtkTreeModel * model; GtkTreeModel * model;
GtkTreeIter iter; GtkTreeIter iter;
GtkTreeModel * view_model;
gboolean loop; gboolean loop;
Account * account; Account * account;
gboolean active; gboolean active;
@ -3021,6 +2989,8 @@ static int _preferences_ok_accounts(Mailer * mailer)
char * p; char * p;
model = gtk_tree_view_get_model(GTK_TREE_VIEW(mailer->pr_accounts)); model = gtk_tree_view_get_model(GTK_TREE_VIEW(mailer->pr_accounts));
view_model = gtk_tree_view_get_model(GTK_TREE_VIEW(
mailer->fo_view));
for(loop = gtk_tree_model_get_iter_first(model, &iter); loop == TRUE; for(loop = gtk_tree_model_get_iter_first(model, &iter); loop == TRUE;
loop = gtk_tree_model_iter_next(model, &iter)) loop = gtk_tree_model_iter_next(model, &iter))
{ {

View File

@ -37,10 +37,10 @@ ldflags=`pkg-config --libs glib-2.0 libSystem` `pkg-config --libs openssl`
type=binary type=binary
#for Gtk+ 2 #for Gtk+ 2
#cflags=`pkg-config --cflags gtk+-2.0` #cflags=`pkg-config --cflags gtk+-2.0`
#ldflags=`pkg-config --libs gtk+-2.0` -ldl #ldflags=`pkg-config --libs gtk+-2.0`
#for Gtk+ 3 #for Gtk+ 3
cflags=`pkg-config --cflags gtk+-3.0` cflags=`pkg-config --cflags gtk+-3.0`
ldflags=`pkg-config --libs gtk+-3.0` -ldl ldflags=`pkg-config --libs gtk+-3.0`
sources=plugins.c sources=plugins.c
[tests.log] [tests.log]