Ejemplo n.º 1
0
/* This function is called when the radio-button is turned on: it deactivates all
 * the other radio-buttons of the group, and activate the given radio-button */
static void _etk_radio_button_active_set(Etk_Toggle_Button *toggle_button, Etk_Bool active)
{
   Etk_Radio_Button *radio_button;
   Etk_Toggle_Button *tb;
   Eina_List *l;

   if (!(radio_button = ETK_RADIO_BUTTON(toggle_button)) || toggle_button->active == active)
      return;

   if (!toggle_button->active || (toggle_button->active && radio_button->can_uncheck))
   {
      toggle_button->active = active;
      etk_signal_emit(ETK_TOGGLE_BUTTON_TOGGLED_SIGNAL, ETK_OBJECT(toggle_button));
      etk_object_notify(ETK_OBJECT(toggle_button), "active");

      if (toggle_button->active)
      {
         /* Deactivate the current active button of the group */
         for (l = *radio_button->group; l; l = l->next)
         {
            tb = ETK_TOGGLE_BUTTON(l->data);
            if (tb != toggle_button && tb->active)
            {
               ETK_RADIO_BUTTON(tb)->can_uncheck = ETK_TRUE;
               etk_toggle_button_active_set(tb, ETK_FALSE);
            }
         }
      }
      radio_button->can_uncheck = ETK_FALSE;
   }
}
Ejemplo n.º 2
0
/* Gets the value of the property whose id is "property_id" */
static void _etk_radio_button_property_get(Etk_Object *object, int property_id, Etk_Property_Value *value)
{
   Etk_Radio_Button *radio_button;

   if (!(radio_button = ETK_RADIO_BUTTON(object)) || !value)
      return;

   switch (property_id)
   {
      case ETK_RADIO_BUTTON_GROUP_PROPERTY:
         etk_property_value_pointer_set(value, radio_button->group);
         break;
      default:
         break;
   }
}
Ejemplo n.º 3
0
static E_Widget *
_e_widget_radio_button_handle(Enhance *en, EXML_Node *node)
{
    E_Widget   *button;
    Etk_Widget *w = NULL;
    char       *label = NULL;
    char       *group = NULL;
    char       *id;
    Ecore_List *props;
    EXML_Node  *prop;

    id = ecore_hash_get(node->attributes, "id");
    if(!id) return NULL;

    props = node->children;
    ecore_list_first_goto(props);
    prop = ecore_list_current(props);
    while(prop != NULL)
    {
        if(!strcmp(prop->tag, "property"))
        {
            char *name;

            name = ecore_hash_get(prop->attributes, "name");
            if(!name) {
                prop = ecore_list_next(props);
                continue;
            }

            if(!strcmp(name, "label"))
            {
                if(prop->value)
                    label = strdup(prop->value);
            }
            else if(!strcmp(name, "group"))
            {
                if(prop->value)
                    group = strdup(prop->value);
            }
        }
        prop = ecore_list_next(props);
    }

    ecore_list_first_goto(props);

    if(group)
        w = eina_hash_find(en->radio_groups, group);

    if(label)
    {
        if(w)
            button = _e_widget_new(en, node,
                                   etk_radio_button_new_with_label_from_widget(label,
                                           ETK_RADIO_BUTTON(w)),
                                   id);
        else
            button = _e_widget_new(en, node,
                                   etk_radio_button_new_with_label(label, NULL),
                                   id);
    }
    else
    {
        if(w)
            button = _e_widget_new(en, node,
                                   etk_radio_button_new_from_widget(ETK_RADIO_BUTTON(w)),
                                   id);
        else
            button = _e_widget_new(en, node, etk_radio_button_new(NULL), id);
    }

    if(!group)
        eina_hash_add(en->radio_groups, id, button->wid);

    E_FREE(label);
    E_FREE(group);

    return button;
}