]> Pileus Git - ~andy/gtk/blob - gtk/gtkcheckmenuitem.c
stylecontext: Do invalidation on first resize container
[~andy/gtk] / gtk / gtkcheckmenuitem.c
1 /* GTK - The GIMP Toolkit
2  * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 /*
19  * Modified by the GTK+ Team and others 1997-2001.  See the AUTHORS
20  * file for a list of people on the GTK+ Team.  See the ChangeLog
21  * files for a list of changes.  These files are distributed with
22  * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
23  */
24
25 #include "config.h"
26 #include "gtkcheckmenuitem.h"
27 #include "gtkmenuitemprivate.h"
28 #include "gtkaccellabel.h"
29 #include "gtkactivatable.h"
30 #include "gtktoggleaction.h"
31 #include "gtkmarshalers.h"
32 #include "gtkprivate.h"
33 #include "gtkintl.h"
34 #include "a11y/gtkcheckmenuitemaccessible.h"
35
36 /**
37  * SECTION:gtkcheckmenuitem
38  * @Short_description: A menu item with a check box
39  * @Title: GtkCheckMenuItem
40  *
41  * A #GtkCheckMenuItem is a menu item that maintains the state of a boolean
42  * value in addition to a #GtkMenuItem usual role in activating application
43  * code.
44  *
45  * A check box indicating the state of the boolean value is displayed
46  * at the left side of the #GtkMenuItem.  Activating the #GtkMenuItem
47  * toggles the value.
48  */
49
50
51 #define INDICATOR_SIZE 16
52
53 struct _GtkCheckMenuItemPrivate
54 {
55   guint active             : 1;
56   guint always_show_toggle : 1;
57   guint draw_as_radio      : 1;
58   guint inconsistent       : 1;
59 };
60
61 enum {
62   TOGGLED,
63   LAST_SIGNAL
64 };
65
66 enum {
67   PROP_0,
68   PROP_ACTIVE,
69   PROP_INCONSISTENT,
70   PROP_DRAW_AS_RADIO
71 };
72
73 static gint gtk_check_menu_item_draw                 (GtkWidget             *widget,
74                                                       cairo_t               *cr);
75 static void gtk_check_menu_item_activate             (GtkMenuItem           *menu_item);
76 static void gtk_check_menu_item_toggle_size_request  (GtkMenuItem           *menu_item,
77                                                       gint                  *requisition);
78 static void gtk_real_check_menu_item_draw_indicator  (GtkCheckMenuItem      *check_menu_item,
79                                                       cairo_t               *cr);
80 static void gtk_check_menu_item_set_property         (GObject               *object,
81                                                       guint                  prop_id,
82                                                       const GValue          *value,
83                                                       GParamSpec            *pspec);
84 static void gtk_check_menu_item_get_property         (GObject               *object,
85                                                       guint                  prop_id,
86                                                       GValue                *value,
87                                                       GParamSpec            *pspec);
88
89 static void gtk_check_menu_item_activatable_interface_init (GtkActivatableIface  *iface);
90 static void gtk_check_menu_item_update                     (GtkActivatable       *activatable,
91                                                             GtkAction            *action,
92                                                             const gchar          *property_name);
93 static void gtk_check_menu_item_sync_action_properties     (GtkActivatable       *activatable,
94                                                             GtkAction            *action);
95
96 static GtkActivatableIface *parent_activatable_iface;
97 static guint                check_menu_item_signals[LAST_SIGNAL] = { 0 };
98
99 G_DEFINE_TYPE_WITH_CODE (GtkCheckMenuItem, gtk_check_menu_item, GTK_TYPE_MENU_ITEM,
100                          G_IMPLEMENT_INTERFACE (GTK_TYPE_ACTIVATABLE,
101                                                 gtk_check_menu_item_activatable_interface_init))
102
103 static void
104 gtk_check_menu_item_class_init (GtkCheckMenuItemClass *klass)
105 {
106   GObjectClass *gobject_class;
107   GtkWidgetClass *widget_class;
108   GtkMenuItemClass *menu_item_class;
109   
110   gobject_class = G_OBJECT_CLASS (klass);
111   widget_class = (GtkWidgetClass*) klass;
112   menu_item_class = (GtkMenuItemClass*) klass;
113   
114   gobject_class->set_property = gtk_check_menu_item_set_property;
115   gobject_class->get_property = gtk_check_menu_item_get_property;
116
117   g_object_class_install_property (gobject_class,
118                                    PROP_ACTIVE,
119                                    g_param_spec_boolean ("active",
120                                                          P_("Active"),
121                                                          P_("Whether the menu item is checked"),
122                                                          FALSE,
123                                                          GTK_PARAM_READWRITE));
124   
125   g_object_class_install_property (gobject_class,
126                                    PROP_INCONSISTENT,
127                                    g_param_spec_boolean ("inconsistent",
128                                                          P_("Inconsistent"),
129                                                          P_("Whether to display an \"inconsistent\" state"),
130                                                          FALSE,
131                                                          GTK_PARAM_READWRITE));
132   
133   g_object_class_install_property (gobject_class,
134                                    PROP_DRAW_AS_RADIO,
135                                    g_param_spec_boolean ("draw-as-radio",
136                                                          P_("Draw as radio menu item"),
137                                                          P_("Whether the menu item looks like a radio menu item"),
138                                                          FALSE,
139                                                          GTK_PARAM_READWRITE));
140   
141   gtk_widget_class_install_style_property (widget_class,
142                                            g_param_spec_int ("indicator-size",
143                                                              P_("Indicator Size"),
144                                                              P_("Size of check or radio indicator"),
145                                                              0,
146                                                              G_MAXINT,
147                                                              INDICATOR_SIZE,
148                                                              GTK_PARAM_READABLE));
149
150   widget_class->draw = gtk_check_menu_item_draw;
151
152   gtk_widget_class_set_accessible_type (widget_class, GTK_TYPE_CHECK_MENU_ITEM_ACCESSIBLE);
153
154   menu_item_class->activate = gtk_check_menu_item_activate;
155   menu_item_class->hide_on_activate = FALSE;
156   menu_item_class->toggle_size_request = gtk_check_menu_item_toggle_size_request;
157   
158   klass->toggled = NULL;
159   klass->draw_indicator = gtk_real_check_menu_item_draw_indicator;
160
161   /**
162    * GtkCheckMenuItem::toggled:
163    * @checkmenuitem: the object which received the signal.
164    *
165    * This signal is emitted when the state of the check box is changed.
166    *
167    * A signal handler can use gtk_check_menu_item_get_active()
168    * to discover the new state.
169    */
170   check_menu_item_signals[TOGGLED] =
171     g_signal_new (I_("toggled"),
172                   G_OBJECT_CLASS_TYPE (gobject_class),
173                   G_SIGNAL_RUN_FIRST,
174                   G_STRUCT_OFFSET (GtkCheckMenuItemClass, toggled),
175                   NULL, NULL,
176                   _gtk_marshal_VOID__VOID,
177                   G_TYPE_NONE, 0);
178
179   g_type_class_add_private (klass, sizeof (GtkCheckMenuItemPrivate));
180 }
181
182 static void 
183 gtk_check_menu_item_activatable_interface_init (GtkActivatableIface  *iface)
184 {
185   parent_activatable_iface = g_type_interface_peek_parent (iface);
186   iface->update = gtk_check_menu_item_update;
187   iface->sync_action_properties = gtk_check_menu_item_sync_action_properties;
188 }
189
190 static void
191 gtk_check_menu_item_update (GtkActivatable *activatable,
192                             GtkAction      *action,
193                             const gchar    *property_name)
194 {
195   GtkCheckMenuItem *check_menu_item;
196
197   check_menu_item = GTK_CHECK_MENU_ITEM (activatable);
198
199   parent_activatable_iface->update (activatable, action, property_name);
200
201   if (strcmp (property_name, "active") == 0)
202     {
203       gtk_action_block_activate (action);
204       gtk_check_menu_item_set_active (check_menu_item, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
205       gtk_action_unblock_activate (action);
206     }
207
208   if (!gtk_activatable_get_use_action_appearance (activatable))
209     return;
210
211   if (strcmp (property_name, "draw-as-radio") == 0)
212     gtk_check_menu_item_set_draw_as_radio (check_menu_item,
213                                            gtk_toggle_action_get_draw_as_radio (GTK_TOGGLE_ACTION (action)));
214 }
215
216 static void
217 gtk_check_menu_item_sync_action_properties (GtkActivatable *activatable,
218                                             GtkAction      *action)
219 {
220   GtkCheckMenuItem *check_menu_item;
221
222   check_menu_item = GTK_CHECK_MENU_ITEM (activatable);
223
224   parent_activatable_iface->sync_action_properties (activatable, action);
225
226   if (!GTK_IS_TOGGLE_ACTION (action))
227     return;
228
229   gtk_action_block_activate (action);
230   gtk_check_menu_item_set_active (check_menu_item, gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)));
231   gtk_action_unblock_activate (action);
232   
233   if (!gtk_activatable_get_use_action_appearance (activatable))
234     return;
235
236   gtk_check_menu_item_set_draw_as_radio (check_menu_item,
237                                          gtk_toggle_action_get_draw_as_radio (GTK_TOGGLE_ACTION (action)));
238 }
239
240 /**
241  * gtk_check_menu_item_new:
242  *
243  * Creates a new #GtkCheckMenuItem.
244  *
245  * Returns: a new #GtkCheckMenuItem.
246  */
247 GtkWidget*
248 gtk_check_menu_item_new (void)
249 {
250   return g_object_new (GTK_TYPE_CHECK_MENU_ITEM, NULL);
251 }
252
253 /**
254  * gtk_check_menu_item_new_with_label:
255  * @label: the string to use for the label.
256  *
257  * Creates a new #GtkCheckMenuItem with a label.
258  *
259  * Returns: a new #GtkCheckMenuItem.
260  */
261 GtkWidget*
262 gtk_check_menu_item_new_with_label (const gchar *label)
263 {
264   return g_object_new (GTK_TYPE_CHECK_MENU_ITEM, 
265                        "label", label,
266                        NULL);
267 }
268
269
270 /**
271  * gtk_check_menu_item_new_with_mnemonic:
272  * @label: The text of the button, with an underscore in front of the
273  *     character
274  *
275  * Creates a new #GtkCheckMenuItem containing a label. The label
276  * will be created using gtk_label_new_with_mnemonic(), so underscores
277  * in @label indicate the mnemonic for the menu item.
278  *
279  * Returns: a new #GtkCheckMenuItem
280  */
281 GtkWidget*
282 gtk_check_menu_item_new_with_mnemonic (const gchar *label)
283 {
284   return g_object_new (GTK_TYPE_CHECK_MENU_ITEM, 
285                        "label", label,
286                        "use-underline", TRUE,
287                        NULL);
288 }
289
290 /**
291  * gtk_check_menu_item_set_active:
292  * @check_menu_item: a #GtkCheckMenuItem.
293  * @is_active: boolean value indicating whether the check box is active.
294  *
295  * Sets the active state of the menu item's check box.
296  */
297 void
298 gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item,
299                                 gboolean          is_active)
300 {
301   GtkCheckMenuItemPrivate *priv;
302
303   g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));
304
305   priv = check_menu_item->priv;
306
307   is_active = is_active != 0;
308
309   if (priv->active != is_active)
310     gtk_menu_item_activate (GTK_MENU_ITEM (check_menu_item));
311 }
312
313 /**
314  * gtk_check_menu_item_get_active:
315  * @check_menu_item: a #GtkCheckMenuItem
316  * 
317  * Returns whether the check menu item is active. See
318  * gtk_check_menu_item_set_active ().
319  * 
320  * Return value: %TRUE if the menu item is checked.
321  */
322 gboolean
323 gtk_check_menu_item_get_active (GtkCheckMenuItem *check_menu_item)
324 {
325   g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item), FALSE);
326
327   return check_menu_item->priv->active;
328 }
329
330 static void
331 gtk_check_menu_item_toggle_size_request (GtkMenuItem *menu_item,
332                                          gint        *requisition)
333 {
334   guint toggle_spacing;
335   guint indicator_size;
336   
337   g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (menu_item));
338   
339   gtk_widget_style_get (GTK_WIDGET (menu_item),
340                         "toggle-spacing", &toggle_spacing,
341                         "indicator-size", &indicator_size,
342                         NULL);
343
344   *requisition = indicator_size + toggle_spacing;
345 }
346
347 /**
348  * gtk_check_menu_item_toggled:
349  * @check_menu_item: a #GtkCheckMenuItem.
350  *
351  * Emits the #GtkCheckMenuItem::toggled signal.
352  */
353 void
354 gtk_check_menu_item_toggled (GtkCheckMenuItem *check_menu_item)
355 {
356   g_signal_emit (check_menu_item, check_menu_item_signals[TOGGLED], 0);
357 }
358
359 /**
360  * gtk_check_menu_item_set_inconsistent:
361  * @check_menu_item: a #GtkCheckMenuItem
362  * @setting: %TRUE to display an "inconsistent" third state check
363  *
364  * If the user has selected a range of elements (such as some text or
365  * spreadsheet cells) that are affected by a boolean setting, and the
366  * current values in that range are inconsistent, you may want to
367  * display the check in an "in between" state. This function turns on
368  * "in between" display.  Normally you would turn off the inconsistent
369  * state again if the user explicitly selects a setting. This has to be
370  * done manually, gtk_check_menu_item_set_inconsistent() only affects
371  * visual appearance, it doesn't affect the semantics of the widget.
372  * 
373  **/
374 void
375 gtk_check_menu_item_set_inconsistent (GtkCheckMenuItem *check_menu_item,
376                                       gboolean          setting)
377 {
378   GtkCheckMenuItemPrivate *priv;
379
380   g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));
381
382   priv = check_menu_item->priv;
383   
384   setting = setting != FALSE;
385
386   if (setting != priv->inconsistent)
387     {
388       priv->inconsistent = setting;
389       gtk_widget_queue_draw (GTK_WIDGET (check_menu_item));
390       g_object_notify (G_OBJECT (check_menu_item), "inconsistent");
391     }
392 }
393
394 /**
395  * gtk_check_menu_item_get_inconsistent:
396  * @check_menu_item: a #GtkCheckMenuItem
397  * 
398  * Retrieves the value set by gtk_check_menu_item_set_inconsistent().
399  * 
400  * Return value: %TRUE if inconsistent
401  **/
402 gboolean
403 gtk_check_menu_item_get_inconsistent (GtkCheckMenuItem *check_menu_item)
404 {
405   g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item), FALSE);
406
407   return check_menu_item->priv->inconsistent;
408 }
409
410 /**
411  * gtk_check_menu_item_set_draw_as_radio:
412  * @check_menu_item: a #GtkCheckMenuItem
413  * @draw_as_radio: whether @check_menu_item is drawn like a #GtkRadioMenuItem
414  *
415  * Sets whether @check_menu_item is drawn like a #GtkRadioMenuItem
416  *
417  * Since: 2.4
418  **/
419 void
420 gtk_check_menu_item_set_draw_as_radio (GtkCheckMenuItem *check_menu_item,
421                                        gboolean          draw_as_radio)
422 {
423   GtkCheckMenuItemPrivate *priv;
424
425   g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item));
426
427   priv = check_menu_item->priv;
428
429   draw_as_radio = draw_as_radio != FALSE;
430
431   if (draw_as_radio != priv->draw_as_radio)
432     {
433       priv->draw_as_radio = draw_as_radio;
434
435       gtk_widget_queue_draw (GTK_WIDGET (check_menu_item));
436
437       g_object_notify (G_OBJECT (check_menu_item), "draw-as-radio");
438     }
439 }
440
441 /**
442  * gtk_check_menu_item_get_draw_as_radio:
443  * @check_menu_item: a #GtkCheckMenuItem
444  * 
445  * Returns whether @check_menu_item looks like a #GtkRadioMenuItem
446  * 
447  * Return value: Whether @check_menu_item looks like a #GtkRadioMenuItem
448  * 
449  * Since: 2.4
450  **/
451 gboolean
452 gtk_check_menu_item_get_draw_as_radio (GtkCheckMenuItem *check_menu_item)
453 {
454   g_return_val_if_fail (GTK_IS_CHECK_MENU_ITEM (check_menu_item), FALSE);
455   
456   return check_menu_item->priv->draw_as_radio;
457 }
458
459 static void
460 gtk_check_menu_item_init (GtkCheckMenuItem *check_menu_item)
461 {
462   GtkCheckMenuItemPrivate *priv;
463
464   check_menu_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (check_menu_item,
465                                                        GTK_TYPE_CHECK_MENU_ITEM,
466                                                        GtkCheckMenuItemPrivate);
467   priv = check_menu_item->priv; 
468
469   priv->active = FALSE;
470   priv->always_show_toggle = TRUE;
471 }
472
473 static gint
474 gtk_check_menu_item_draw (GtkWidget *widget,
475                           cairo_t   *cr)
476 {
477   GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (widget);
478
479   if (GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->draw)
480     GTK_WIDGET_CLASS (gtk_check_menu_item_parent_class)->draw (widget, cr);
481
482   if (GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->draw_indicator)
483     GTK_CHECK_MENU_ITEM_GET_CLASS (check_menu_item)->draw_indicator (check_menu_item, cr);
484
485   return FALSE;
486 }
487
488 static void
489 gtk_check_menu_item_activate (GtkMenuItem *menu_item)
490 {
491   GtkCheckMenuItemPrivate *priv;
492
493   GtkCheckMenuItem *check_menu_item = GTK_CHECK_MENU_ITEM (menu_item);
494   priv = check_menu_item->priv;
495
496   priv->active = !priv->active;
497
498   gtk_check_menu_item_toggled (check_menu_item);
499   gtk_widget_queue_draw (GTK_WIDGET (check_menu_item));
500
501   GTK_MENU_ITEM_CLASS (gtk_check_menu_item_parent_class)->activate (menu_item);
502
503   g_object_notify (G_OBJECT (check_menu_item), "active");
504 }
505
506 static void
507 gtk_real_check_menu_item_draw_indicator (GtkCheckMenuItem *check_menu_item,
508                                          cairo_t          *cr)
509 {
510   GtkCheckMenuItemPrivate *priv = check_menu_item->priv;
511   GtkWidget *widget;
512   gint x, y;
513
514   widget = GTK_WIDGET (check_menu_item);
515
516   if (gtk_widget_is_drawable (widget))
517     {
518       GtkAllocation allocation;
519       GtkStyleContext *context;
520       guint border_width;
521       guint offset;
522       guint toggle_size;
523       guint toggle_spacing;
524       guint horizontal_padding;
525       guint indicator_size;
526       GtkStateFlags state;
527       GtkBorder padding;
528
529       context = gtk_widget_get_style_context (widget);
530       state = gtk_widget_get_state_flags (widget);
531       gtk_style_context_get_padding (context, state, &padding);
532
533       gtk_widget_get_allocation (widget, &allocation);
534
535       gtk_widget_style_get (widget,
536                             "toggle-spacing", &toggle_spacing,
537                             "horizontal-padding", &horizontal_padding,
538                             "indicator-size", &indicator_size,
539                             NULL);
540
541       toggle_size = GTK_MENU_ITEM (check_menu_item)->priv->toggle_size;
542       border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
543       offset = border_width + padding.left + 2;
544
545       if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
546         {
547           x = offset + horizontal_padding +
548             (toggle_size - toggle_spacing - indicator_size) / 2;
549         }
550       else
551         {
552           x = allocation.width -
553             offset - horizontal_padding - toggle_size + toggle_spacing +
554             (toggle_size - toggle_spacing - indicator_size) / 2;
555         }
556
557       y = (allocation.height - indicator_size) / 2;
558
559       if (priv->active ||
560           priv->always_show_toggle ||
561           (state & GTK_STATE_FLAG_PRELIGHT))
562         {
563           gtk_style_context_save (context);
564
565           if (priv->inconsistent)
566             state |= GTK_STATE_FLAG_INCONSISTENT;
567           else if (priv->active)
568             state |= GTK_STATE_FLAG_ACTIVE;
569
570           gtk_style_context_set_state (context, state);
571
572           if (priv->draw_as_radio)
573             {
574               gtk_style_context_add_class (context, GTK_STYLE_CLASS_RADIO);
575               gtk_render_option (context, cr, x, y,
576                                  indicator_size, indicator_size);
577             }
578           else
579             {
580               gtk_style_context_add_class (context, GTK_STYLE_CLASS_CHECK);
581               gtk_render_check (context, cr, x, y,
582                                 indicator_size, indicator_size);
583             }
584
585           gtk_style_context_restore (context);
586         }
587     }
588 }
589
590
591 static void
592 gtk_check_menu_item_get_property (GObject     *object,
593                                   guint        prop_id,
594                                   GValue      *value,
595                                   GParamSpec  *pspec)
596 {
597   GtkCheckMenuItem *checkitem = GTK_CHECK_MENU_ITEM (object);
598   GtkCheckMenuItemPrivate *priv = checkitem->priv;
599   
600   switch (prop_id)
601     {
602     case PROP_ACTIVE:
603       g_value_set_boolean (value, priv->active);
604       break;
605     case PROP_INCONSISTENT:
606       g_value_set_boolean (value, priv->inconsistent);
607       break;
608     case PROP_DRAW_AS_RADIO:
609       g_value_set_boolean (value, priv->draw_as_radio);
610       break;
611     default:
612       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
613       break;
614     }
615 }
616
617
618 static void
619 gtk_check_menu_item_set_property (GObject      *object,
620                                   guint         prop_id,
621                                   const GValue *value,
622                                   GParamSpec   *pspec)
623 {
624   GtkCheckMenuItem *checkitem = GTK_CHECK_MENU_ITEM (object);
625   
626   switch (prop_id)
627     {
628     case PROP_ACTIVE:
629       gtk_check_menu_item_set_active (checkitem, g_value_get_boolean (value));
630       break;
631     case PROP_INCONSISTENT:
632       gtk_check_menu_item_set_inconsistent (checkitem, g_value_get_boolean (value));
633       break;
634     case PROP_DRAW_AS_RADIO:
635       gtk_check_menu_item_set_draw_as_radio (checkitem, g_value_get_boolean (value));
636       break;
637     default:
638       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
639       break;
640     }
641 }
642
643
644 /* Private */
645
646 /*
647  * _gtk_check_menu_item_set_active:
648  * @check_menu_item: a #GtkCheckMenuItem
649  * @is_active: whether the action is active or not
650  *
651  * Sets the #GtkCheckMenuItem:active property directly. This function does
652  * not emit signals or notifications: it is left to the caller to do so.
653  */
654 void
655 _gtk_check_menu_item_set_active (GtkCheckMenuItem *check_menu_item,
656                                  gboolean          is_active)
657 {
658   GtkCheckMenuItemPrivate *priv = check_menu_item->priv;
659
660   priv->active = is_active;
661 }