[Commits] [SCM] claws branch, master, updated. 3.15.0-89-g7bf56c1

ticho at claws-mail.org ticho at claws-mail.org
Tue Jul 11 00:13:04 CEST 2017


The branch, master has been updated
       via  7bf56c150c8290b02db31a7db62081dd6aa6e4ff (commit)
      from  03110aad38b148ab2fe0b6ad0e67b2904fb2aae0 (commit)

Summary of changes:
 src/compose.c |   16 +++++++---
 src/compose.h |    3 ++
 src/toolbar.c |   99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/toolbar.h |    5 +++
 4 files changed, 118 insertions(+), 5 deletions(-)


- Log -----------------------------------------------------------------
commit 7bf56c150c8290b02db31a7db62081dd6aa6e4ff
Author: Andrej Kacian <ticho at claws-mail.org>
Date:   Fri Jul 7 15:28:25 2017 +0200

    Add Sign/Encrypt toggle buttons to Compose toolbar.

diff --git a/src/compose.c b/src/compose.c
index 08e765b..4ff2363 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -490,8 +490,6 @@ static void compose_update_privacy_system_menu_item(Compose * compose, gboolean
 static void activate_privacy_system     (Compose *compose, 
                                          PrefsAccount *account,
 					 gboolean warn);
-static void compose_use_signing(Compose *compose, gboolean use_signing);
-static void compose_use_encryption(Compose *compose, gboolean use_encryption);
 static void compose_toggle_return_receipt_cb(GtkToggleAction *action,
 					 gpointer	 data);
 static void compose_toggle_remove_refs_cb(GtkToggleAction *action,
@@ -2757,6 +2755,10 @@ void compose_toolbar_cb(gint action, gpointer data)
 		compose_check_all(NULL, compose);
 		break;
 #endif
+	case A_PRIVACY_SIGN:
+		break;
+	case A_PRIVACY_ENCRYPT:
+		break;
 	default:
 		break;
 	}
@@ -3871,13 +3873,13 @@ static gboolean compose_attach_append(Compose *compose, const gchar *file,
 	return TRUE;
 }
 
-static void compose_use_signing(Compose *compose, gboolean use_signing)
+void compose_use_signing(Compose *compose, gboolean use_signing)
 {
 	compose->use_signing = use_signing;
 	cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/Sign", use_signing);
 }
 
-static void compose_use_encryption(Compose *compose, gboolean use_encryption)
+void compose_use_encryption(Compose *compose, gboolean use_encryption)
 {
 	compose->use_encryption = use_encryption;
 	cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/Encrypt", use_encryption);
@@ -8470,6 +8472,10 @@ static void compose_set_privacy_system_cb(GtkWidget *widget, gpointer data)
 
 	cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options/Sign", can_sign);
 	cm_menu_set_sensitive_full(compose->ui_manager, "Menu/Options/Encrypt", can_encrypt);
+	gtk_widget_set_sensitive(compose->toolbar->privacy_sign_btn, can_sign);
+	gtk_widget_set_sensitive(compose->toolbar->privacy_encrypt_btn, can_encrypt);
+	gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(compose->toolbar->privacy_sign_btn), can_sign ? compose->use_signing : FALSE);
+	gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(compose->toolbar->privacy_encrypt_btn), can_encrypt ? compose->use_encryption : FALSE);
 }
 
 static void compose_update_privacy_system_menu_item(Compose * compose, gboolean warn)
@@ -11386,6 +11392,7 @@ static void compose_toggle_sign_cb(GtkToggleAction *action, gpointer data)
 	Compose *compose = (Compose *)data;
 
 	compose->use_signing = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+	gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(compose->toolbar->privacy_sign_btn), compose->use_signing);
 }
 
 static void compose_toggle_encrypt_cb(GtkToggleAction *action, gpointer data)
@@ -11393,6 +11400,7 @@ static void compose_toggle_encrypt_cb(GtkToggleAction *action, gpointer data)
 	Compose *compose = (Compose *)data;
 
 	compose->use_encryption = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+	gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(compose->toolbar->privacy_encrypt_btn), compose->use_encryption);
 }
 
 static void activate_privacy_system(Compose *compose, PrefsAccount *account, gboolean warn) 
diff --git a/src/compose.h b/src/compose.h
index cca482d..ddfc63f 100644
--- a/src/compose.h
+++ b/src/compose.h
@@ -344,4 +344,7 @@ void compose_reopen_exit_drafts		(void);
 void compose_attach_from_list (Compose *compose, GList *file_list, gboolean free_data);
 void compose_check_for_email_account(Compose *compose);
 
+void compose_use_signing(Compose *compose, gboolean use_signing);
+void compose_use_encryption(Compose *compose, gboolean use_encryption);
+
 #endif /* __COMPOSE_H__ */
diff --git a/src/toolbar.c b/src/toolbar.c
index ca83855..b1add59 100644
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -269,6 +269,8 @@ struct {
 #ifdef USE_ENCHANT
 	{ "A_CHECK_SPELLING",	N_("Check spelling")                       },
 #endif
+	{ "A_PRIVACY_SIGN",     N_("Sign")                                 },
+	{ "A_PRIVACY_ENCRYPT",  N_("Encrypt")                              },
 	{ "A_CLAWS_ACTIONS",   	N_("Claws Mail Actions Feature")           }, 
 	{ "A_CANCEL_INC",       N_("Cancel receiving")                     },
 	{ "A_CANCEL_SEND",      N_("Cancel sending")                       },
@@ -393,6 +395,7 @@ GList *toolbar_get_action_items(ToolbarType source)
 #ifdef USE_ENCHANT
 					A_CHECK_SPELLING,
 #endif
+					A_PRIVACY_SIGN, A_PRIVACY_ENCRYPT,
 					A_CLOSE };
 
 		for (i = 0; i < sizeof comp_items / sizeof comp_items[0]; i++) 
@@ -527,6 +530,8 @@ const gchar *toolbar_get_short_text(int action) {
 	#ifdef USE_ENCHANT
 	case A_CHECK_SPELLING:	return _("Check spelling");
 	#endif
+	case A_PRIVACY_SIGN:	return _("Sign");
+	case A_PRIVACY_ENCRYPT:	return _("Encrypt");
 
 	case A_CANCEL_INC:	return _("Stop");
 	case A_CANCEL_SEND:	return _("Stop");
@@ -586,6 +591,8 @@ gint toolbar_get_icon(int action) {
 	#ifdef USE_ENCHANT
 	case A_CHECK_SPELLING:	return STOCK_PIXMAP_CHECK_SPELLING;
 	#endif
+	case A_PRIVACY_SIGN:	return STOCK_PIXMAP_PRIVACY_EMBLEM_SIGNED;
+	case A_PRIVACY_ENCRYPT:	return STOCK_PIXMAP_PRIVACY_EMBLEM_ENCRYPTED;
 
 	case A_CANCEL_INC:	return STOCK_PIXMAP_CANCEL;
 	case A_CANCEL_SEND:	return STOCK_PIXMAP_CANCEL;
@@ -1889,6 +1896,49 @@ static void toolbar_check_spelling_cb(GtkWidget *widget, gpointer data)
 	compose_toolbar_cb(A_CHECK_SPELLING, data);
 }
 #endif
+
+static void toolbar_privacy_sign_cb(GtkWidget *widget, gpointer data)
+{
+	ToolbarItem *toolbar_item = (ToolbarItem*)data;
+	Compose *compose = (Compose *)toolbar_item->parent;
+	gboolean state = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget));
+
+	cm_return_if_fail(compose != NULL);
+	compose_use_signing(compose, state);
+}
+
+/* Any time the toggle button gets toggled, we want to update its tooltip. */
+static void toolbar_privacy_sign_toggled_cb(GtkWidget *widget, gpointer data)
+{
+	gboolean state = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget));
+
+	if (state)
+		gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), _("Message will be signed"));
+	else
+		gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), _("Message will not be signed"));
+}
+
+static void toolbar_privacy_encrypt_cb(GtkWidget *widget, gpointer data)
+{
+	ToolbarItem *toolbar_item = (ToolbarItem*)data;
+	Compose *compose = (Compose *)toolbar_item->parent;
+	gboolean state = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget));
+
+	cm_return_if_fail(compose != NULL);
+	compose_use_encryption(compose, state);
+}
+
+/* Any time the toggle button gets toggled, we want to update its tooltip. */
+static void toolbar_privacy_encrypt_toggled_cb(GtkWidget *widget, gpointer data)
+{
+	gboolean state = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(widget));
+
+	if (state)
+		gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), _("Message will be encrypted"));
+	else
+		gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(widget), _("Message will not be encrypted"));
+}
+
 /*
  * Execute actions from toolbar
  */
@@ -2032,6 +2082,8 @@ static void toolbar_buttons_cb(GtkWidget   *widget,
 #ifdef USE_ENCHANT
 		{ A_CHECK_SPELLING,     toolbar_check_spelling_cb       },
 #endif
+		{ A_PRIVACY_SIGN,	toolbar_privacy_sign_cb		},
+		{ A_PRIVACY_ENCRYPT,	toolbar_privacy_encrypt_cb	},
 		{ A_CLAWS_ACTIONS,	toolbar_actions_execute_cb	},
 		{ A_CANCEL_INC,		toolbar_cancel_inc_cb		},
 		{ A_CANCEL_SEND,	toolbar_cancel_send_cb		},
@@ -2060,6 +2112,19 @@ static void toolbar_buttons_cb(GtkWidget   *widget,
 			tooltip);									\
 }
 
+#define TOOLBAR_TOGGLE_ITEM(item,icon,text,tooltip) {							\
+	item = GTK_WIDGET(gtk_toggle_tool_button_new());						\
+	gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), icon);					\
+	gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), text);						\
+	gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE);				\
+	gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE);					\
+	gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE);					\
+	g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item);	\
+	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);				\
+	CLAWS_SET_TOOL_ITEM_TIP(GTK_TOOL_ITEM(item), 							\
+			tooltip);									\
+}
+
 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) {						\
 	GtkWidget *child = NULL, *btn = NULL, *arr = NULL;						\
 	GList *gchild = NULL;										\
@@ -2083,7 +2148,9 @@ static void toolbar_buttons_cb(GtkWidget   *widget,
 	gtk_widget_set_size_request(GTK_WIDGET(gchild->data), 9, -1);					\
 	g_list_free(gchild);										\
 }
+
 #else
+
 #define TOOLBAR_ITEM(item,icon,text,tooltip) {								\
 	item = GTK_WIDGET(gtk_tool_button_new(icon, text));						\
 	gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE);				\
@@ -2093,6 +2160,17 @@ static void toolbar_buttons_cb(GtkWidget   *widget,
 	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);				\
 }
 
+#define TOOLBAR_TOGGLE_ITEM(item,icon,text,tooltip) {							\
+	item = GTK_WIDGET(gtk_toggle_tool_button_new());						\
+	gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), icon);					\
+	gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), text);						\
+	gtkut_widget_set_can_focus(gtk_bin_get_child(GTK_BIN(item)), FALSE);				\
+	gtk_tool_item_set_homogeneous(GTK_TOOL_ITEM(item), FALSE);					\
+	gtk_tool_item_set_is_important(GTK_TOOL_ITEM(item), TRUE);					\
+	g_signal_connect (G_OBJECT(item), "clicked", G_CALLBACK(toolbar_buttons_cb), toolbar_item);	\
+	gtk_toolbar_insert(GTK_TOOLBAR(toolbar), GTK_TOOL_ITEM(item), -1);				\
+}
+
 #define TOOLBAR_MENUITEM(item,icon,text,tooltip,menutip) {						\
 	GtkWidget *child = NULL, *btn = NULL, *arr = NULL;						\
 	GList *gchild = NULL;										\
@@ -2447,6 +2525,22 @@ Toolbar *toolbar_create(ToolbarType 	 type,
 			toolbar_data->spellcheck_btn = item;
 			break;
 #endif
+		case A_PRIVACY_SIGN:
+			TOOLBAR_TOGGLE_ITEM(item,icon_wid,toolbar_item->text,_("Sign"));
+			g_signal_connect (G_OBJECT(item), "toggled",
+					G_CALLBACK(toolbar_privacy_sign_toggled_cb), NULL);
+			/* Call the "toggled" handler to set correct tooltip. */
+			toolbar_privacy_sign_toggled_cb(item, NULL);
+			toolbar_data->privacy_sign_btn = item;
+			break;
+		case A_PRIVACY_ENCRYPT:
+			TOOLBAR_TOGGLE_ITEM(item,icon_wid,toolbar_item->text,_("Encrypt"));
+			g_signal_connect (G_OBJECT(item), "toggled",
+					G_CALLBACK(toolbar_privacy_encrypt_toggled_cb), NULL);
+			/* Call the "toggled" handler to set correct tooltip. */
+			toolbar_privacy_encrypt_toggled_cb(item, NULL);
+			toolbar_data->privacy_encrypt_btn = item;
+			break;
 
 		case A_CLAWS_ACTIONS:
 			TOOLBAR_ITEM(item,icon_wid,toolbar_item->text,toolbar_item->text);
@@ -2515,7 +2609,7 @@ Toolbar *toolbar_create(ToolbarType 	 type,
  */ 
 void toolbar_destroy(Toolbar * toolbar) {
 
-	TOOLBAR_DESTROY_ITEMS(toolbar->item_list);	
+	TOOLBAR_DESTROY_ITEMS(toolbar->item_list);
 	TOOLBAR_DESTROY_ACTIONS(toolbar->action_list);
 }
 
@@ -2846,6 +2940,9 @@ static void toolbar_init(Toolbar * toolbar)
 	toolbar->spellcheck_btn    = NULL;
 #endif
 
+	toolbar->privacy_sign_btn  = NULL;
+	toolbar->privacy_encrypt_btn = NULL;
+
 	toolbar_destroy(toolbar);
 }
 
diff --git a/src/toolbar.h b/src/toolbar.h
index c9aaf4f..ef82456 100644
--- a/src/toolbar.h
+++ b/src/toolbar.h
@@ -108,6 +108,9 @@ struct _Toolbar {
 #ifdef USE_ENCHANT
 	GtkWidget *spellcheck_btn;
 #endif
+
+	GtkWidget *privacy_sign_btn;
+	GtkWidget *privacy_encrypt_btn;
 };
 
 struct _ToolbarItem {
@@ -204,6 +207,8 @@ enum {
 #ifdef USE_ENCHANT
 	A_CHECK_SPELLING,
 #endif
+	A_PRIVACY_SIGN,
+	A_PRIVACY_ENCRYPT,
 
 	/* common items */
 	A_CLAWS_ACTIONS,

-----------------------------------------------------------------------


hooks/post-receive
-- 
Claws Mail


More information about the Commits mailing list