Exemple #1
0
/* Called when the iconbox is pressed by the mouse */
static Etk_Bool _etk_test_iconbox_mouse_down_cb(Etk_Object *object, Etk_Event_Mouse_Up *event, void *data)
{
   Etk_Iconbox *iconbox;
   Etk_Iconbox_Icon *icon;
   Etk_String *new_folder;
   char *parent;

   if (!(iconbox = ETK_ICONBOX(object)))
      return ETK_TRUE;
   if (event->button != 1 || !(event->flags & ETK_MOUSE_DOUBLE_CLICK) || (event->flags & ETK_MOUSE_TRIPLE_CLICK))
      return ETK_TRUE;
   if (!(icon = etk_iconbox_icon_get_at_xy(iconbox, event->canvas.x, event->canvas.y, ETK_FALSE, ETK_TRUE, ETK_TRUE)))
      return ETK_TRUE;

   if (!strcmp(etk_iconbox_icon_label_get(icon), ".."))
   {
      parent = ecore_file_dir_get(etk_string_get(_etk_test_iconbox_current_folder));
      _etk_test_iconbox_folder_set(iconbox, parent);
      free(parent);
   }
   else
   {
      if (etk_string_length_get(_etk_test_iconbox_current_folder) == 1)
         new_folder = etk_string_new_printf("/%s", etk_iconbox_icon_label_get(icon));
      else
         new_folder = etk_string_new_printf("%s/%s", etk_string_get(_etk_test_iconbox_current_folder),
                                            etk_iconbox_icon_label_get(icon));
      _etk_test_iconbox_folder_set(iconbox, etk_string_get(new_folder));
      etk_object_destroy(ETK_OBJECT(new_folder));
   }
   
   return ETK_TRUE;
}
Exemple #2
0
void evolve_gui_general_table_populate(Evolve_Widget *widget)
{
   Etk_Widget *label;
   Etk_Widget *entry;
   Etk_Type *type;
   Eina_List *l, *list = NULL;
   char *str;
   int i = 2;
   
   if (!widget || !widget->type || !(type = evolve_widget_type_to_etk(widget->type)))
     return;

   etk_type_property_list(type, &list);
   
   etk_table_resize(ETK_TABLE(_evolve_gui_gen_table), 0, 0);
   etk_table_resize(ETK_TABLE(_evolve_gui_gen_table), 2, eina_list_count(list) + 2);
   
   label = etk_label_new("Class:");
   entry = etk_entry_new();
   etk_entry_text_set(ETK_ENTRY(entry), type->name);
   etk_widget_disabled_set(entry, ETK_TRUE);   
   etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), label,
			    0, 0, 0, 0);
   etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), entry,
			    1, 1, 0, 0);
   
   label = etk_label_new("Name:");
   entry = etk_entry_new();
   etk_entry_text_set(ETK_ENTRY(entry), widget->name);
   etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), label,
			    0, 0, 1, 1);
   etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), entry,
			    1, 1, 1, 1);   

   for (l = list; l; l = l->next)
     {
	Evolve_Property *prop;
	Evolve_Property *eprop;
	Evolve_Property *p;
	Etk_String *value;
	Etk_Widget *vwidget;
	
	if (!(prop = l->data))
	  continue;
	
	str = evolve_util_string_humanize(prop->name);	
	label = etk_label_new(str);
	free(str);
	
	eprop = evolve_widget_property_get(widget, prop->name);
	if (eprop && eprop->default_value)	  
	  p = eprop;	  
	else
	  p = prop;
	
	switch(prop->type)
	  {
	   case EVOLVE_PROPERTY_INT:
	     value = etk_string_new_printf("%d", evolve_property_value_int_get(p->default_value));
	     vwidget = etk_spinner_new(0, 9999, evolve_property_value_int_get(p->default_value), 1, 10);
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL);
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "widget", widget, NULL);
	     etk_signal_connect("value-changed", ETK_OBJECT(vwidget),
				ETK_CALLBACK(evolve_gui_property_spinner_value_changed_cb),
				NULL);
	     break;
	   case EVOLVE_PROPERTY_BOOL:
	     value = etk_string_new_printf("%d", evolve_property_value_bool_get(p->default_value));
	     vwidget = etk_combobox_new_default();
	       {
		  Etk_Combobox_Item *item;
		  
		  item = etk_combobox_item_append(ETK_COMBOBOX(vwidget), "True");
		  if (evolve_property_value_bool_get(p->default_value))
		    etk_combobox_active_item_set(ETK_COMBOBOX(vwidget), item);
		  item = etk_combobox_item_append(ETK_COMBOBOX(vwidget), "False");
		  if (!evolve_property_value_bool_get(p->default_value))
		    etk_combobox_active_item_set(ETK_COMBOBOX(vwidget), item);		  
	       }
	     break;
	   case EVOLVE_PROPERTY_CHAR:
	     value = etk_string_new_printf("%c", evolve_property_value_char_get(p->default_value));
	     vwidget = etk_entry_new();
	     etk_entry_text_set(ETK_ENTRY(vwidget), etk_string_get(value));
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL);
	     etk_signal_connect("text-changed", ETK_OBJECT(vwidget),
				ETK_CALLBACK(evolve_gui_property_entry_text_changed_cb),
				widget);
	     break;		  
	   case EVOLVE_PROPERTY_FLOAT:
	     value = etk_string_new_printf("%f", evolve_property_value_float_get(p->default_value));
	     vwidget = etk_spinner_new(0.0, 9999.0, evolve_property_value_float_get(p->default_value), 0.1, 1.0);
	     etk_spinner_digits_set(ETK_SPINNER(vwidget), 1);
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL);
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "widget", widget, NULL);
	     etk_signal_connect("value-changed", ETK_OBJECT(vwidget),
				ETK_CALLBACK(evolve_gui_property_spinner_value_changed_cb),
				NULL);
	     break;
	   case EVOLVE_PROPERTY_DOUBLE:
	     value = etk_string_new_printf("%g", evolve_property_value_double_get(p->default_value));
	     vwidget = etk_spinner_new(0.0, 9999.0, evolve_property_value_double_get(p->default_value), 0.1, 1.0);
	     etk_spinner_digits_set(ETK_SPINNER(vwidget), 1);
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL);
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "widget", widget, NULL);
	     etk_signal_connect("value-changed", ETK_OBJECT(vwidget),
				ETK_CALLBACK(evolve_gui_property_spinner_value_changed_cb),
				NULL);
	     break;
	   case EVOLVE_PROPERTY_SHORT:
	     value = etk_string_new_printf("%d", evolve_property_value_short_get(p->default_value));
	     vwidget = etk_spinner_new(0, 9999, evolve_property_value_short_get(p->default_value), 1, 10);
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL);
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "widget", widget, NULL);
	     etk_signal_connect("value-changed", ETK_OBJECT(vwidget),
				ETK_CALLBACK(evolve_gui_property_spinner_value_changed_cb),
				NULL);	     
	     break;
	   case EVOLVE_PROPERTY_LONG:
	     value = etk_string_new_printf("%li", evolve_property_value_long_get(p->default_value));
	     vwidget = etk_spinner_new(0, 9999, evolve_property_value_long_get(p->default_value), 1, 10);
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL);
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "widget", widget, NULL);
	     etk_signal_connect("value-changed", ETK_OBJECT(vwidget),
				ETK_CALLBACK(evolve_gui_property_spinner_value_changed_cb),
				NULL);
	     break;
	   case EVOLVE_PROPERTY_POINTER:
	     value = etk_string_new_printf("cant cast PROPERTY_POINTER");
	     vwidget = etk_entry_new();
	     etk_entry_text_set(ETK_ENTRY(vwidget), etk_string_get(value));
	     etk_widget_disabled_set(vwidget, ETK_TRUE);
	     break;		  
	   case EVOLVE_PROPERTY_STRING:
	     value = etk_string_new_printf("%s", evolve_property_value_string_get(p->default_value));
	     vwidget = etk_entry_new();
	     etk_entry_text_set(ETK_ENTRY(vwidget), etk_string_get(value));
	     etk_entry_text_set(ETK_ENTRY(vwidget), etk_string_get(value));
	     etk_object_data_set_full(ETK_OBJECT(vwidget), "prop", p, NULL);
	     etk_signal_connect("text-changed", ETK_OBJECT(vwidget),
				ETK_CALLBACK(evolve_gui_property_entry_text_changed_cb),
				widget);	     
	     break;
	   default:
	     value = etk_string_new_printf("cant determine value");
	     vwidget = etk_entry_new();
	     etk_entry_text_set(ETK_ENTRY(vwidget), etk_string_get(value));
	     break;
	  }	
	
	if (p == prop)
	  {
	     int type;
	     
	     type = prop->type;	     
	     evolve_widget_property_set(widget, prop->name, etk_string_get(value), type);
	     eprop = evolve_widget_property_get(widget, prop->name);	     
	  }
	
	etk_object_destroy(ETK_OBJECT(value));
	
	etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), label,
				  0, 0, i, i);
	etk_table_attach_default(ETK_TABLE(_evolve_gui_gen_table), vwidget,
				  1, 1, i, i);
	++i;
     }

   etk_widget_show_all(_evolve_gui_gen_table);      
}