gtkcheckmenuitem.c 18.7 KB
Newer Older
Cody Russell's avatar
Cody Russell committed
1
/* GTK - The GIMP Toolkit
Elliot Lee's avatar
Elliot Lee committed
2 3 4
 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
 *
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Lesser General Public
Elliot Lee's avatar
Elliot Lee committed
6 7 8 9 10 11
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Lesser General Public License for more details.
Elliot Lee's avatar
Elliot Lee committed
13
 *
14
 * You should have received a copy of the GNU Lesser General Public
15 16 17
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
18
 */
19 20

/*
21
 * Modified by the GTK+ Team and others 1997-2001.  See the AUTHORS
22 23 24 25 26
 * file for a list of people on the GTK+ Team.  See the ChangeLog
 * files for a list of changes.  These files are distributed with
 * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
 */

27
#include "config.h"
Elliot Lee's avatar
Elliot Lee committed
28
#include "gtkcheckmenuitem.h"
Tim Janik's avatar
Tim Janik committed
29
#include "gtkaccellabel.h"
30 31
#include "gtkactivatable.h"
#include "gtktoggleaction.h"
32
#include "gtkmarshalers.h"
33 34
#include "gtkprivate.h"
#include "gtkintl.h"
35

Elliot Lee's avatar
Elliot Lee committed
36

37

38
struct _GtkCheckMenuItemPrivate
39 40 41 42 43 44 45
{
  guint active             : 1;
  guint always_show_toggle : 1;
  guint draw_as_radio      : 1;
  guint inconsistent       : 1;
};

Elliot Lee's avatar
Elliot Lee committed
46 47 48 49 50
enum {
  TOGGLED,
  LAST_SIGNAL
};

51 52 53
enum {
  PROP_0,
  PROP_ACTIVE,
54 55
  PROP_INCONSISTENT,
  PROP_DRAW_AS_RADIO
56
};
Elliot Lee's avatar
Elliot Lee committed
57

58 59
static gint gtk_check_menu_item_draw                 (GtkWidget             *widget,
                                                      cairo_t               *cr);
60 61
static void gtk_check_menu_item_activate             (GtkMenuItem           *menu_item);
static void gtk_check_menu_item_toggle_size_request  (GtkMenuItem           *menu_item,
62
						      gint                  *requisition);
63
static void gtk_real_check_menu_item_draw_indicator  (GtkCheckMenuItem      *check_menu_item,
64
						      cairo_t               *cr);
65 66 67 68 69 70 71 72 73 74
static void gtk_check_menu_item_set_property         (GObject               *object,
						      guint                  prop_id,
						      const GValue          *value,
						      GParamSpec            *pspec);
static void gtk_check_menu_item_get_property         (GObject               *object,
						      guint                  prop_id,
						      GValue                *value,
						      GParamSpec            *pspec);

static void gtk_check_menu_item_activatable_interface_init (GtkActivatableIface  *iface);
75
static void gtk_check_menu_item_update                     (GtkActivatable       *activatable,
76 77
							    GtkAction            *action,
							    const gchar          *property_name);
78
static void gtk_check_menu_item_sync_action_properties     (GtkActivatable       *activatable,
79 80 81 82 83 84 85 86
							    GtkAction            *action);

static GtkActivatableIface *parent_activatable_iface;
static guint                check_menu_item_signals[LAST_SIGNAL] = { 0 };

G_DEFINE_TYPE_WITH_CODE (GtkCheckMenuItem, gtk_check_menu_item, GTK_TYPE_MENU_ITEM,
			 G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
						gtk_check_menu_item_activatable_interface_init))
Elliot Lee's avatar
Elliot Lee committed
87

88 89 90
static void
gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass)
{
Manish Singh's avatar
Manish Singh committed
91
  GObjectClass *gobject_class;
92 93 94
  GtkWidgetClass *widget_class;
  GtkMenuItemClass *menu_item_class;
  
Manish Singh's avatar
Manish Singh committed
95
  gobject_class = G_OBJECT_CLASS (klass);
96 97 98
  widget_class = (GtkWidgetClass*) klass;
  menu_item_class = (GtkMenuItemClass*) klass;
  
Manish Singh's avatar
Manish Singh committed
99 100
  gobject_class->set_property = gtk_check_menu_item_set_property;
  gobject_class->get_property = gtk_check_menu_item_get_property;
101

Manish Singh's avatar
Manish Singh committed
102
  g_object_class_install_property (gobject_class,
103 104
                                   PROP_ACTIVE,
                                   g_param_spec_boolean ("active",
105 106
                                                         P_("Active"),
                                                         P_("Whether the menu item is checked"),
107
                                                         FALSE,
108
                                                         GTK_PARAM_READWRITE));
109
  
Manish Singh's avatar
Manish Singh committed
110
  g_object_class_install_property (gobject_class,
Owen Taylor's avatar
Owen Taylor committed
111
                                   PROP_INCONSISTENT,
112
                                   g_param_spec_boolean ("inconsistent",
113 114
                                                         P_("Inconsistent"),
                                                         P_("Whether to display an \"inconsistent\" state"),
115
                                                         FALSE,
116
                                                         GTK_PARAM_READWRITE));
117
  
118
  g_object_class_install_property (gobject_class,
119
                                   PROP_DRAW_AS_RADIO,
120
                                   g_param_spec_boolean ("draw-as-radio",
121 122
                                                         P_("Draw as radio menu item"),
                                                         P_("Whether the menu item looks like a radio menu item"),
123
                                                         FALSE,
124
                                                         GTK_PARAM_READWRITE));
125
  
126
  gtk_widget_class_install_style_property (widget_class,
127
                                           g_param_spec_int ("indicator-size",
128
                                                             P_("Indicator Size"),
129 130 131
                                                             P_("Size of check or radio indicator"),
                                                             0,
                                                             G_MAXINT,
132
                                                             13,
133
                                                             GTK_PARAM_READABLE));
134

135
  widget_class->draw = gtk_check_menu_item_draw;
136 137 138
  
  menu_item_class->activate = gtk_check_menu_item_activate;
  menu_item_class->hide_on_activate = FALSE;
139
  menu_item_class->toggle_size_request = gtk_check_menu_item_toggle_size_request;
140 141 142 143 144
  
  klass->toggled = NULL;
  klass->draw_indicator = gtk_real_check_menu_item_draw_indicator;

  check_menu_item_signals[TOGGLED] =
Matthias Clasen's avatar
Matthias Clasen committed
145
    g_signal_new (I_("toggled"),
Manish Singh's avatar
Manish Singh committed
146 147 148 149 150 151
		  G_OBJECT_CLASS_TYPE (gobject_class),
		  G_SIGNAL_RUN_FIRST,
		  G_STRUCT_OFFSET (GtkCheckMenuItemClass, toggled),
		  NULL, NULL,
		  _gtk_marshal_VOID__VOID,
		  G_TYPE_NONE, 0);
152

153
  g_type_class_add_private (klass, sizeof (GtkCheckMenuItemPrivate));
154 155
}

156 157 158 159
static void 
gtk_check_menu_item_activatable_interface_init (GtkActivatableIface  *iface)
{
  parent_activatable_iface = g_type_interface_peek_parent (iface);
160 161
  iface->update = gtk_check_menu_item_update;
  iface->sync_action_properties = gtk_check_menu_item_sync_action_properties;
162 163
}

164 165 166 167
static void
gtk_check_menu_item_update (GtkActivatable *activatable,
			    GtkAction      *action,
			    const gchar    *property_name)
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
{
  GtkCheckMenuItem *check_menu_item;

  check_menu_item = GTK_CHECK_MENU_ITEM (activatable);

  parent_activatable_iface->update (activatable, action, property_name);

  if (strcmp (property_name, "active") == 0)
    {
      gtk_action_block_activate (action);
      gtk_check_menu_item_set_active (check_menu_item, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
      gtk_action_unblock_activate (action);
    }

  if (!gtk_activatable_get_use_action_appearance (activatable))
    return;

  if (strcmp (property_name, "draw-as-radio") == 0)
186
    gtk_check_menu_item_set_draw_as_radio (check_menu_item,
187 188 189
					   gtk_toggle_action_get_draw_as_radio (GTK_TOGGLE_ACTION (action)));
}

190 191 192
static void
gtk_check_menu_item_sync_action_properties (GtkActivatable *activatable,
		                            GtkAction      *action)
193 194 195 196 197
{
  GtkCheckMenuItem *check_menu_item;

  check_menu_item = GTK_CHECK_MENU_ITEM (activatable);

198
  parent_activatable_iface->sync_action_properties (activatable, action);
199

200
  if (!GTK_IS_TOGGLE_ACTION (action))
201 202 203 204 205 206 207 208 209
    return;

  gtk_action_block_activate (action);
  gtk_check_menu_item_set_active (check_menu_item, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
  gtk_action_unblock_activate (action);
  
  if (!gtk_activatable_get_use_action_appearance (activatable))
    return;

210
  gtk_check_menu_item_set_draw_as_radio (check_menu_item,
211 212 213
					 gtk_toggle_action_get_draw_as_radio (GTK_TOGGLE_ACTION (action)));
}

Elliot Lee's avatar
Elliot Lee committed
214
GtkWidget*
215
gtk_check_menu_item_new (void)
Elliot Lee's avatar
Elliot Lee committed
216
{
Manish Singh's avatar
Manish Singh committed
217
  return g_object_new (GTK_TYPE_CHECK_MENU_ITEM, NULL);
Elliot Lee's avatar
Elliot Lee committed
218 219 220 221 222
}

GtkWidget*
gtk_check_menu_item_new_with_label (const gchar *label)
{
223 224 225
  return g_object_new (GTK_TYPE_CHECK_MENU_ITEM, 
		       "label", label,
		       NULL);
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241
}


/**
 * gtk_check_menu_item_new_with_mnemonic:
 * @label: The text of the button, with an underscore in front of the
 *         mnemonic character
 * @returns: a new #GtkCheckMenuItem
 *
 * Creates a new #GtkCheckMenuItem containing a label. The label
 * will be created using gtk_label_new_with_mnemonic(), so underscores
 * in @label indicate the mnemonic for the menu item.
 **/
GtkWidget*
gtk_check_menu_item_new_with_mnemonic (const gchar *label)
{
242 243 244 245
  return g_object_new (GTK_TYPE_CHECK_MENU_ITEM, 
		       "label", label,
		       "use-underline", TRUE,
		       NULL);
Elliot Lee's avatar
Elliot Lee committed
246 247
}

248 249 250
void
gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item,
				gboolean          is_active)
Elliot Lee's avatar
Elliot Lee committed
251
{
252
  GtkCheckMenuItemPrivate *priv;
253

Elliot Lee's avatar
Elliot Lee committed
254 255
  g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));

256 257
  priv = check_menu_item->priv;

258 259
  is_active = is_active != 0;

260
  if (priv->active != is_active)
261
    gtk_menu_item_activate (GTK_MENU_ITEM (check_menu_item));
Elliot Lee's avatar
Elliot Lee committed
262 263
}

264 265 266 267 268 269 270 271 272 273 274 275 276 277
/**
 * gtk_check_menu_item_get_active:
 * @check_menu_item: a #GtkCheckMenuItem
 * 
 * Returns whether the check menu item is active. See
 * gtk_check_menu_item_set_active ().
 * 
 * Return value: %TRUE if the menu item is checked.
 */
gboolean
gtk_check_menu_item_get_active (GtkCheckMenuItem *check_menu_item)
{
  g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item), FALSE);

278
  return check_menu_item->priv->active;
279 280
}

281 282
static void
gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
283
					 gint        *requisition)
284
{
285
  guint toggle_spacing;
286
  guint indicator_size;
287
  
288
  g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (menu_item));
289 290
  
  gtk_widget_style_get (GTK_WIDGET (menu_item),
291 292
			"toggle-spacing", &toggle_spacing,
			"indicator-size", &indicator_size,
293
			NULL);
294 295

  *requisition = indicator_size + toggle_spacing;
296 297
}

Elliot Lee's avatar
Elliot Lee committed
298 299 300
void
gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_item)
{
Manish Singh's avatar
Manish Singh committed
301
  g_signal_emit (check_menu_item, check_menu_item_signals[TOGGLED], 0);
Elliot Lee's avatar
Elliot Lee committed
302 303
}

304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
/**
 * gtk_check_menu_item_set_inconsistent:
 * @check_menu_item: a #GtkCheckMenuItem
 * @setting: %TRUE to display an "inconsistent" third state check
 *
 * If the user has selected a range of elements (such as some text or
 * spreadsheet cells) that are affected by a boolean setting, and the
 * current values in that range are inconsistent, you may want to
 * display the check in an "in between" state. This function turns on
 * "in between" display.  Normally you would turn off the inconsistent
 * state again if the user explicitly selects a setting. This has to be
 * done manually, gtk_check_menu_item_set_inconsistent() only affects
 * visual appearance, it doesn't affect the semantics of the widget.
 * 
 **/
void
gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
                                      gboolean          setting)
{
323
  GtkCheckMenuItemPrivate *priv;
324

325
  g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));
326 327

  priv = check_menu_item->priv;
328 329 330
  
  setting = setting != FALSE;

331
  if (setting != priv->inconsistent)
332
    {
333
      priv->inconsistent = setting;
334
      gtk_widget_queue_draw (GTK_WIDGET (check_menu_item));
335
      g_object_notify (G_OBJECT (check_menu_item), "inconsistent");
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351
    }
}

/**
 * gtk_check_menu_item_get_inconsistent:
 * @check_menu_item: a #GtkCheckMenuItem
 * 
 * Retrieves the value set by gtk_check_menu_item_set_inconsistent().
 * 
 * Return value: %TRUE if inconsistent
 **/
gboolean
gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item)
{
  g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item), FALSE);

352
  return check_menu_item->priv->inconsistent;
353 354
}

355 356 357 358 359 360 361
/**
 * gtk_check_menu_item_set_draw_as_radio:
 * @check_menu_item: a #GtkCheckMenuItem
 * @draw_as_radio: whether @check_menu_item is drawn like a #GtkRadioMenuItem
 *
 * Sets whether @check_menu_item is drawn like a #GtkRadioMenuItem
 *
Matthias Clasen's avatar
Matthias Clasen committed
362
 * Since: 2.4
363 364 365 366 367
 **/
void
gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_item,
				       gboolean          draw_as_radio)
{
368
  GtkCheckMenuItemPrivate *priv;
369

370
  g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));
371 372 373

  priv = check_menu_item->priv;

374 375
  draw_as_radio = draw_as_radio != FALSE;

376
  if (draw_as_radio != priv->draw_as_radio)
377
    {
378
      priv->draw_as_radio = draw_as_radio;
379 380 381

      gtk_widget_queue_draw (GTK_WIDGET (check_menu_item));

382
      g_object_notify (G_OBJECT (check_menu_item), "draw-as-radio");
383 384 385 386 387 388 389 390 391 392
    }
}

/**
 * gtk_check_menu_item_get_draw_as_radio:
 * @check_menu_item: a #GtkCheckMenuItem
 * 
 * Returns whether @check_menu_item looks like a #GtkRadioMenuItem
 * 
 * Return value: Whether @check_menu_item looks like a #GtkRadioMenuItem
Matthias Clasen's avatar
Matthias Clasen committed
393 394
 * 
 * Since: 2.4
395 396 397 398 399 400
 **/
gboolean
gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item)
{
  g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item), FALSE);
  
401
  return check_menu_item->priv->draw_as_radio;
402 403
}

Elliot Lee's avatar
Elliot Lee committed
404 405 406
static void
gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item)
{
407
  GtkCheckMenuItemPrivate *priv;
408 409 410

  check_menu_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (check_menu_item,
                                                       GTK_TYPE_CHECK_MENU_ITEM,
411
                                                       GtkCheckMenuItemPrivate);
412 413 414 415
  priv = check_menu_item->priv; 

  priv->active = FALSE;
  priv->always_show_toggle = TRUE;
Elliot Lee's avatar
Elliot Lee committed
416 417 418
}

static gint
419 420
gtk_check_menu_item_draw (GtkWidget *widget,
                          cairo_t   *cr)
Elliot Lee's avatar
Elliot Lee committed
421
{
422
  GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (widget);
Elliot Lee's avatar
Elliot Lee committed
423

424 425 426 427 428
  if (GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->draw)
    GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->draw (widget, cr);

  if (GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->draw_indicator)
    GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->draw_indicator (check_menu_item, cr);
Elliot Lee's avatar
Elliot Lee committed
429 430 431 432 433 434 435

  return FALSE;
}

static void
gtk_check_menu_item_activate (GtkMenuItem *menu_item)
{
436
  GtkCheckMenuItemPrivate *priv;
437

438
  GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (menu_item);
439 440 441
  priv = check_menu_item->priv;

  priv->active = !priv->active;
Elliot Lee's avatar
Elliot Lee committed
442 443 444

  gtk_check_menu_item_toggled (check_menu_item);
  gtk_widget_queue_draw (GTK_WIDGET (check_menu_item));
445

446 447
  GTK_MENU_ITEM_CLASS (gtk_check_menu_item_parent_class)->activate (menu_item);

448
  g_object_notify (G_OBJECT (check_menu_item), "active");
Elliot Lee's avatar
Elliot Lee committed
449 450 451 452
}

static void
gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
453
					 cairo_t          *cr)
Elliot Lee's avatar
Elliot Lee committed
454
{
455
  GtkCheckMenuItemPrivate *priv = check_menu_item->priv;
Elliot Lee's avatar
Elliot Lee committed
456 457 458 459 460
  GtkWidget *widget;
  GtkStateType state_type;
  GtkShadowType shadow_type;
  gint x, y;

461 462 463
  widget = GTK_WIDGET (check_menu_item);

  if (gtk_widget_is_drawable (widget))
Elliot Lee's avatar
Elliot Lee committed
464
    {
465 466
      GtkAllocation allocation;
      GtkStyle *style;
467
      guint border_width;
468 469 470 471
      guint offset;
      guint toggle_size;
      guint toggle_spacing;
      guint horizontal_padding;
472
      guint indicator_size;
Elliot Lee's avatar
Elliot Lee committed
473

474 475 476
      style = gtk_widget_get_style (widget);
      gtk_widget_get_allocation (widget, &allocation);

477
      gtk_widget_style_get (widget,
478 479 480
 			    "toggle-spacing", &toggle_spacing,
 			    "horizontal-padding", &horizontal_padding,
			    "indicator-size", &indicator_size,
481 482 483
 			    NULL);

      toggle_size = GTK_MENU_ITEM (check_menu_item)->toggle_size;
484
      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
485
      offset = border_width + style->xthickness + 2;
486 487 488

      if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
	{
489
          x = offset + horizontal_padding +
490
	    (toggle_size - toggle_spacing - indicator_size) / 2;
491
	}
492
      else 
493
	{
494
          x = allocation.width -
495
	    offset - horizontal_padding - toggle_size + toggle_spacing +
496
	    (toggle_size - toggle_spacing - indicator_size) / 2;
497
	}
498

499
      y = (allocation.height - indicator_size) / 2;
Elliot Lee's avatar
Elliot Lee committed
500

501 502
      if (priv->active ||
	  priv->always_show_toggle ||
503
	  (gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT))
Elliot Lee's avatar
Elliot Lee committed
504
	{
505 506 507
          GdkWindow *window;

          window = gtk_widget_get_window (widget);
508
	  state_type = gtk_widget_get_state (widget);
509
	  
510
	  if (priv->inconsistent)
511
	    shadow_type = GTK_SHADOW_ETCHED_IN;
512
	  else if (priv->active)
513 514 515 516
	    shadow_type = GTK_SHADOW_IN;
	  else 
	    shadow_type = GTK_SHADOW_OUT;
	  
517
	  if (!gtk_widget_is_sensitive (widget))
518 519
	    state_type = GTK_STATE_INSENSITIVE;

520
	  if (priv->draw_as_radio)
521
	    {
522
              gtk_cairo_paint_option (style, cr,
523
				state_type, shadow_type,
524
				widget, "option",
525
				x, y, indicator_size, indicator_size);
526 527 528
	    }
	  else
	    {
529
              gtk_cairo_paint_check (style, cr,
530
			       state_type, shadow_type,
531
			       widget, "check",
532
			       x, y, indicator_size, indicator_size);
533
	    }
Elliot Lee's avatar
Elliot Lee committed
534 535 536
	}
    }
}
537 538 539 540 541 542 543 544 545


static void
gtk_check_menu_item_get_property (GObject     *object,
				  guint        prop_id,
				  GValue      *value,
				  GParamSpec  *pspec)
{
  GtkCheckMenuItem *checkitem = GTK_CHECK_MENU_ITEM (object);
546
  GtkCheckMenuItemPrivate *priv = checkitem->priv;
547 548 549 550
  
  switch (prop_id)
    {
    case PROP_ACTIVE:
551
      g_value_set_boolean (value, priv->active);
552 553
      break;
    case PROP_INCONSISTENT:
554
      g_value_set_boolean (value, priv->inconsistent);
555
      break;
556
    case PROP_DRAW_AS_RADIO:
557
      g_value_set_boolean (value, priv->draw_as_radio);
558
      break;
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}


static void
gtk_check_menu_item_set_property (GObject      *object,
				  guint         prop_id,
				  const GValue *value,
				  GParamSpec   *pspec)
{
  GtkCheckMenuItem *checkitem = GTK_CHECK_MENU_ITEM (object);
  
  switch (prop_id)
    {
    case PROP_ACTIVE:
      gtk_check_menu_item_set_active (checkitem, g_value_get_boolean (value));
      break;
    case PROP_INCONSISTENT:
      gtk_check_menu_item_set_inconsistent (checkitem, g_value_get_boolean (value));
      break;
582 583 584
    case PROP_DRAW_AS_RADIO:
      gtk_check_menu_item_set_draw_as_radio (checkitem, g_value_get_boolean (value));
      break;
585 586 587 588 589
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}
590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605


/* Private */

/*
 * _gtk_check_menu_item_set_active:
 * @check_menu_item: a #GtkCheckMenuItem
 * @is_active: whether the action is active or not
 *
 * Sets the #GtkCheckMenuItem:active property directly. This function does
 * not emit signals or notifications: it is left to the caller to do so.
 */
void
_gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item,
                                 gboolean          is_active)
{
606
  GtkCheckMenuItemPrivate *priv = check_menu_item->priv;
607 608 609

  priv->active = is_active;
}