/*Function to make standard menu items*/
static Etk_Widget *_entropy_etk_menu_item_new(Etk_Menu_Item_Type item_type, const char *label,
   Etk_Stock_Id stock_id, Etk_Menu_Shell *menu_shell, Etk_Widget *statusbar)
{
   Etk_Widget *menu_item = NULL;
   
   switch (item_type)
   {
      case ETK_MENU_ITEM_NORMAL:
         menu_item = etk_menu_item_image_new_with_label(label);
         break;
      case ETK_MENU_ITEM_SEPARATOR:
         menu_item = etk_menu_item_separator_new();
         break;
      default:
         return NULL;
   }
   if (stock_id != ETK_STOCK_NO_STOCK)
   {
      Etk_Widget *image;
      
      image = etk_image_new_from_stock(stock_id, ETK_STOCK_SMALL);
      etk_menu_item_image_set(ETK_MENU_ITEM_IMAGE(menu_item), ETK_IMAGE(image));
   }
   etk_menu_shell_append(menu_shell, ETK_MENU_ITEM(menu_item));
   
   /*etk_signal_connect("selected", ETK_OBJECT(menu_item), ETK_CALLBACK(_etk_test_menu_item_selected_cb), statusbar);
   etk_signal_connect("deselected", ETK_OBJECT(menu_item), ETK_CALLBACK(_etk_test_menu_item_deselected_cb), statusbar);*/
   
   return menu_item;
}
Beispiel #2
0
/**
 * @brief Make a menu with small stock image and sets a callback on "activated" on each elements
 * @param menu The Etk_Menu to setup
 * @param ... An (char*)menu_item name, an (Etk_Stock_Id)image id, a Etk_Callback function and 
 * it data ... terminated by NULL
 */
void
emphasis_menu_append(Etk_Widget *menu, ...)
{
  Etk_Widget *menu_item, *item_image = NULL;
  char *item_name;
  Etk_Stock_Id item_image_id;
  void *callback, *data;
  va_list arglist;

  va_start(arglist, menu);

  while ((item_name = va_arg(arglist, char *)) != NULL)
    {
      menu_item = etk_menu_item_image_new_with_label(item_name);
      item_image_id = va_arg(arglist, Etk_Stock_Id);
      if (item_image_id)
        {
          item_image =
            etk_image_new_from_stock(item_image_id, ETK_STOCK_SMALL);
          etk_menu_item_image_set(ETK_MENU_ITEM_IMAGE(menu_item),
                                  ETK_IMAGE(item_image));
        }
      callback = va_arg(arglist, void *);
      data = va_arg(arglist, void *);
      if (callback)
        {
          etk_signal_connect("activated", ETK_OBJECT(menu_item),
                             ETK_CALLBACK(callback), data);
        }

      etk_menu_shell_append(ETK_MENU_SHELL(menu), ETK_MENU_ITEM(menu_item));
    }
  va_end(arglist);
}
Beispiel #3
0
/* Menu_Item_Image: Sets the property whose id is "property_id" to the value "value" */
static void _etk_menu_item_image_property_set(Etk_Object *object, int property_id, Etk_Property_Value *value)
{
   Etk_Menu_Item_Image *image_item;

   if (!(image_item = ETK_MENU_ITEM_IMAGE(object)) || !value)
      return;

   switch (property_id)
   {
      case ETK_MENU_ITEM_IMAGE_PROPERTY:
         etk_menu_item_image_set(image_item, ETK_IMAGE(etk_property_value_object_get(value)));
         break;
      default:
         break;
   }
}
Beispiel #4
0
/**
 * @brief Sets the label of the menu-item from a stock-id. If the menu-item is an Etk_Menu_Item_Image,
 * the image is also changed depending on the stock-id
 * @param menu_item a menu-item
 * @param stock_id the stock-id corresponding to the label and the image you want to use
 * @see Etk_Stock
 */
void etk_menu_item_set_from_stock(Etk_Menu_Item *menu_item, Etk_Stock_Id stock_id)
{
   const char *label;

   if (!menu_item)
      return;

   label = etk_stock_label_get(stock_id);
   etk_menu_item_label_set(menu_item, label);

   if (ETK_IS_MENU_ITEM_IMAGE(menu_item))
   {
      Etk_Widget *image;

      image = etk_image_new_from_stock(stock_id, ETK_STOCK_SMALL);
      etk_menu_item_image_set(ETK_MENU_ITEM_IMAGE(menu_item), ETK_IMAGE(image));
      etk_widget_internal_set(image, ETK_TRUE);
      etk_widget_show(image);
   }
}