* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#include <config.h>
-#include "intl.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <gtk/gtk.h>
-
#include "main.h"
#include "layout.h"
#include "ui-menu.h"
label = g_strdup(gtk_menu_item_get_label(GTK_MENU_ITEM(menu)));
- pango_parse_markup(label, -1, '_', NULL, &label_text, NULL, NULL);
+ pango_parse_markup(label, -1, '_', nullptr, &label_text, nullptr, nullptr);
label_stripped = g_strsplit(label_text, "...", 2);
- while (window_keys[i].text != NULL)
+ while (window_keys[i].text != nullptr)
{
if (g_strcmp0(window_keys[i].text, label_stripped[0]) == 0)
{
- gtk_widget_add_accelerator(menu, "activate", accel_group, window_keys[i].key_value, (GdkModifierType)window_keys[i].mask, GTK_ACCEL_VISIBLE);
+ gtk_widget_add_accelerator(menu, "activate", accel_group, window_keys[i].key_value, window_keys[i].mask, GTK_ACCEL_VISIBLE);
break;
}
menu_label = g_strdup(gtk_menu_item_get_label(GTK_MENU_ITEM(menu)));
- pango_parse_markup(menu_label, -1, '_', NULL, &menu_label_text, NULL, NULL);
+ pango_parse_markup(menu_label, -1, '_', nullptr, &menu_label_text, nullptr, nullptr);
- lw = layout_window_list->data; /* get the actions from the first window, it should not matter, they should be the same in all windows */
+ lw = static_cast<LayoutWindow *>(layout_window_list->data); /* get the actions from the first window, it should not matter, they should be the same in all windows */
g_assert(lw && lw->ui_manager);
groups = gtk_ui_manager_get_action_groups(lw->ui_manager);
{
g_object_get(action, "label", &action_label, NULL);
- pango_parse_markup(action_label, -1, '_', NULL, &action_label_text, NULL, NULL);
+ pango_parse_markup(action_label, -1, '_', nullptr, &action_label_text, nullptr, nullptr);
if (g_strcmp0(action_label_text, menu_label_text) == 0)
{
hard_coded_window_keys *window_keys;
item = gtk_menu_item_new_with_mnemonic(label);
- window_keys = g_object_get_data(G_OBJECT(menu), "window_keys");
- accel_group = g_object_get_data(G_OBJECT(menu), "accel_group");
+ window_keys = static_cast<hard_coded_window_keys *>(g_object_get_data(G_OBJECT(menu), "window_keys"));
+ accel_group = static_cast<GtkAccelGroup *>(g_object_get_data(G_OBJECT(menu), "accel_group"));
if (accel_group && window_keys)
{
hard_coded_window_keys *window_keys;
item = gtk_image_menu_item_new_with_mnemonic(label);
- window_keys = g_object_get_data(G_OBJECT(menu), "window_keys");
- accel_group = g_object_get_data(G_OBJECT(menu), "accel_group");
+ window_keys = static_cast<hard_coded_window_keys *>(g_object_get_data(G_OBJECT(menu), "window_keys"));
+ accel_group = static_cast<GtkAccelGroup *>(g_object_get_data(G_OBJECT(menu), "accel_group"));
image = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_MENU);
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
return item;
}
+GtkWidget *menu_item_add_icon(GtkWidget *menu, const gchar *label, const gchar *icon_name,
+ GCallback func, gpointer data)
+{
+ GtkWidget *item;
+ GtkWidget *image;
+ GtkAccelGroup *accel_group;
+ hard_coded_window_keys *window_keys;
+
+ item = gtk_image_menu_item_new_with_mnemonic(label);
+ window_keys = static_cast<hard_coded_window_keys *>(g_object_get_data(G_OBJECT(menu), "window_keys"));
+ accel_group = static_cast<GtkAccelGroup *>(g_object_get_data(G_OBJECT(menu), "accel_group"));
+
+ image = gtk_image_new_from_icon_name(icon_name, GTK_ICON_SIZE_MENU);
+ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
+
+ if (accel_group && window_keys)
+ {
+ menu_item_add_accelerator(item, accel_group, window_keys);
+ }
+ else if (accel_group)
+ {
+ menu_item_add_main_window_accelerator(item, accel_group);
+ }
+
+ gtk_widget_show(image);
+ menu_item_finish(menu, item, func, data);
+
+ return item;
+}
+
GtkWidget *menu_item_add_sensitive(GtkWidget *menu, const gchar *label, gboolean sensitive,
GCallback func, gpointer data)
{
item = menu_item_add(menu, label, func, data);
gtk_widget_set_sensitive(item, sensitive);
- window_keys = g_object_get_data(G_OBJECT(menu), "window_keys");
- accel_group = g_object_get_data(G_OBJECT(menu), "accel_group");
+ window_keys = static_cast<hard_coded_window_keys *>(g_object_get_data(G_OBJECT(menu), "window_keys"));
+ accel_group = static_cast<GtkAccelGroup *>(g_object_get_data(G_OBJECT(menu), "accel_group"));
if (accel_group && window_keys)
{
menu_item_add_accelerator(item, accel_group, window_keys);
item = menu_item_add_stock(menu, label, stock_id, func, data);
gtk_widget_set_sensitive(item, sensitive);
- window_keys = g_object_get_data(G_OBJECT(menu), "window_keys");
- accel_group = g_object_get_data(G_OBJECT(menu), "accel_group");
+ window_keys = static_cast<hard_coded_window_keys *>(g_object_get_data(G_OBJECT(menu), "window_keys"));
+ accel_group = static_cast<GtkAccelGroup *>(g_object_get_data(G_OBJECT(menu), "accel_group"));
+ if (accel_group && window_keys)
+ {
+ menu_item_add_accelerator(item, accel_group, window_keys);
+ }
+ else if (accel_group)
+ {
+ menu_item_add_main_window_accelerator(item, accel_group);
+ }
+
+ return item;
+}
+
+GtkWidget *menu_item_add_icon_sensitive(GtkWidget *menu, const gchar *label, const gchar *icon_name, gboolean sensitive,
+ GCallback func, gpointer data)
+{
+ GtkWidget *item;
+ GtkAccelGroup *accel_group;
+ hard_coded_window_keys *window_keys;
+
+ item = menu_item_add_icon(menu, label, icon_name, func, data);
+ gtk_widget_set_sensitive(item, sensitive);
+ window_keys = static_cast<hard_coded_window_keys *>(g_object_get_data(G_OBJECT(menu), "window_keys"));
+ accel_group = static_cast<GtkAccelGroup *>(g_object_get_data(G_OBJECT(menu), "accel_group"));
if (accel_group && window_keys)
{
menu_item_add_accelerator(item, accel_group, window_keys);
hard_coded_window_keys *window_keys;
item = gtk_check_menu_item_new_with_mnemonic(label);
- window_keys = g_object_get_data(G_OBJECT(menu), "window_keys");
- accel_group = g_object_get_data(G_OBJECT(menu), "accel_group");
+ window_keys = static_cast<hard_coded_window_keys *>(g_object_get_data(G_OBJECT(menu), "window_keys"));
+ accel_group = static_cast<GtkAccelGroup *>(g_object_get_data(G_OBJECT(menu), "accel_group"));
if (accel_group && window_keys)
{
g_object_set_data(G_OBJECT(item), "menu_item_radio_data", item_data);
g_object_set(G_OBJECT(item), "draw-as-radio", TRUE, NULL);
- window_keys = g_object_get_data(G_OBJECT(menu), "window_keys");
- accel_group = g_object_get_data(G_OBJECT(menu), "accel_group");
+ window_keys = static_cast<hard_coded_window_keys *>(g_object_get_data(G_OBJECT(menu), "window_keys"));
+ accel_group = static_cast<GtkAccelGroup *>(g_object_get_data(G_OBJECT(menu), "accel_group"));
if (accel_group && window_keys)
{
menu_item_add_accelerator(item, accel_group, window_keys);
*-----------------------------------------------------------------------------
*/
-static void popup_menu_short_lived_cb(GtkWidget *UNUSED(widget), gpointer data)
+static void popup_menu_short_lived_cb(GtkWidget *, gpointer data)
{
/* destroy the menu */
g_object_unref(G_OBJECT(data));
}
-GtkWidget *popup_menu_short_lived(void)
+GtkWidget *popup_menu_short_lived()
{
GtkWidget *menu;