/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2012 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2013 Hiroyuki Yamamoto and 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
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#if !GTK_CHECK_VERSION(3, 0, 0)
#include "gtkcmoptionmenu.h"
-#endif
#include "menu.h"
#include "utils.h"
#include "gtkutils.h"
-
-#ifdef MAEMO
-#ifdef CHINOOK
-#include <hildon/hildon-program.h>
-#else
-#include <hildon-widgets/hildon-program.h>
-#endif
-#endif
+#include "defs.h"
GtkActionGroup *cm_menu_create_action_group(const gchar *name, GtkActionEntry *entries,
gint num_entries, gpointer data)
g_free(path);
}
-void cm_menu_set_sensitive_full(GtkUIManager *gui_manager, gchar *menu, gboolean sensitive)
+void cm_menu_set_sensitive_full(GtkUIManager *gui_manager, const gchar *menu, gboolean sensitive)
{
GtkWidget *widget;
gchar *path = g_strdup_printf("/%s/", menu);
}
gtk_widget_set_sensitive(widget, sensitive);
+
+ if (strcmp(menu, "Menus/SummaryViewPopup/Reedit") == 0)
+ (sensitive)? gtk_widget_show(widget) : gtk_widget_hide(widget);
+
g_free(path);
}
}
+GtkWidget *cm_menu_item_new_label_from_url(gchar *url)
+{
+ gint len = strlen(url);
+ if (len > MAX_MENU_LABEL_LENGTH) {
+ g_message("Refusing a %d bytes string as menu label\n", len);
+ url[64] = '\0', url[63] = url[62] = url[61] = '.', url[60] = ' ';
+ GtkWidget *newlabel = gtk_menu_item_new_with_label(url);
+ gtk_widget_set_tooltip_markup(GTK_WIDGET(newlabel),
+ g_strconcat("<span><b>", _("Warning:"), "</b>",
+ _("This URL was too long for displaying and\n"
+ "has been truncated for safety. This message could be\n"
+ "corrupted, malformed or part of some DoS attempt."),
+ "</span>", NULL));
+ return newlabel;
+ }
+
+ return gtk_menu_item_new_with_label(url);
+}
+
void cm_toggle_menu_set_active_full(GtkUIManager *gui_manager, gchar *menu, gboolean active)
{
GtkWidget *widget;
*y -= mreq.height;
}
-#if !GTK_CHECK_VERSION(3, 0, 0)
gint menu_find_option_menu_index(GtkCMOptionMenu *optmenu, gpointer data,
GCompareFunc func)
{
gpointer menu_data;
GList *children;
GList *cur;
- gint n;
+ gint n, found = -1;
menu = gtk_cmoption_menu_get_menu(optmenu);
children = gtk_container_get_children(GTK_CONTAINER(GTK_MENU_SHELL(menu)));
menu_data = g_object_get_data(G_OBJECT(menuitem),
MENU_VAL_ID);
if (func) {
- if (func(menu_data, data) == 0)
- return n;
- } else if (menu_data == data)
- return n;
+ if (func(menu_data, data) == 0) {
+ found = n;
+ break;
+ }
+ } else if (menu_data == data) {
+ found = n;
+ break;
+ }
}
g_list_free(children);
- return -1;
+ return found;
}
-#endif