Exemplo n.º 1
0
static void _etk_layout_row_clicked(Etk_Object *object, 
		Etk_Tree_Row *row, Etk_Event_Mouse_Down *event, void *data)
{
	entropy_gui_component_instance* instance = data;
	entropy_layout_gui* gui = instance->data;	
	Entropy_Config_Structure* structure;

	structure = ecore_hash_get(_etk_layout_row_reference, row);

	if (event->button == 3 && structure) {
		gui->delete_row = row;
		
		etk_tree_row_select(row);
		etk_menu_popup(ETK_MENU(gui->popup));
	}
	
}
Exemplo n.º 2
0
/* Menu_Item: Sets the property whose id is "property_id" to the value "value" */
static void _etk_menu_item_property_set(Etk_Object *object, int property_id, Etk_Property_Value *value)
{
   Etk_Menu_Item *menu_item;

   if (!(menu_item = ETK_MENU_ITEM(object)) || !value)
      return;

   switch (property_id)
   {
      case ETK_MENU_ITEM_LABEL_PROPERTY:
         etk_menu_item_label_set(menu_item, etk_property_value_string_get(value));
         break;
      case ETK_MENU_ITEM_SUBMENU_PROPERTY:
         etk_menu_item_submenu_set(menu_item, ETK_MENU(etk_property_value_object_get(value)));
         break;
      default:
         break;
   }
}
Exemplo n.º 3
0
entropy_gui_component_instance *
entropy_plugin_layout_create (entropy_core * core)
{
  Etk_Widget *window;
  entropy_layout_gui *gui;
  entropy_gui_component_instance *layout;

  void *(*local_plugin_init) (entropy_core * core,
				  entropy_gui_component_instance *,
				  void *data);
  entropy_plugin *local;

  entropy_plugin *meta;
  entropy_plugin *hover;
  entropy_plugin *trackback;
  entropy_gui_component_instance* meta_instance;
  entropy_gui_component_instance* hover_instance;
	  
  Etk_Tree_Col* col;
  Etk_Widget* vbox;
  Etk_Widget* menubar;
  Etk_Widget* menu_item;
  Etk_Widget* menu;

  Eina_List* structures;
  Entropy_Config_Structure* structure;
  int local_viewer_selected = 0;


  /*Entropy related init */
  layout = (entropy_gui_component_instance*)entropy_gui_component_instance_layout_new(); /*Create a component instance */
  gui = entropy_malloc (sizeof (entropy_layout_gui));
  layout->data = gui;
  layout->core = core;
  gui->progress_hash = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);
  gui->properties_request_hash = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);

  /*Global init for all layouts*/
  if (!_etk_layout_global_init) {
	  /*Request metadata groups from evfs*/
	entropy_plugin_filesystem_metadata_groups_get(layout);
	  
	  _etk_layout_row_reference = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);
	  _etk_layout_structure_plugin_reference = ecore_hash_new(ecore_direct_hash, ecore_direct_compare);
	  
	  _etk_layout_global_init = 1;
  }


  /*Register this layout container with the core, so our children can get events */
  entropy_core_layout_register (core, layout);


  /*Register this instance (the layout itself), to receive events that can be safely handled
   * by the layout (and reduce the clutter in the child plugins)
   * i.e. PROGRESS events, Stat for properties, Overwrite yes/no/etc events, etc*/

  /*Handle progress events*/
  entropy_core_component_event_register (layout,
					 entropy_core_gui_event_get
					 (ENTROPY_GUI_EVENT_FILE_PROGRESS));

    /*We want to know if the backend needs feedback */
  entropy_core_component_event_register (layout,
					 entropy_core_gui_event_get
					 (ENTROPY_GUI_EVENT_USER_INTERACTION_YES_NO_ABORT));

    /*We want to know if a stat is an 'extended stat' - e.g. a properties dialog etc */
  entropy_core_component_event_register (layout,
					 entropy_core_gui_event_get
					 (ENTROPY_GUI_EVENT_EXTENDED_STAT));

  entropy_core_component_event_register (layout,
					 entropy_core_gui_event_get
					 (ENTROPY_GUI_EVENT_FILE_STAT));
  entropy_core_component_event_register (layout,
					 entropy_core_gui_event_get
					 (ENTROPY_GUI_EVENT_FILE_STAT_AVAILABLE));

  entropy_core_component_event_register (layout,
					 entropy_core_gui_event_get
					 (ENTROPY_GUI_EVENT_METADATA_GROUPS));

  entropy_core_component_event_register (layout,
					 entropy_core_gui_event_get
					 (ENTROPY_GUI_EVENT_PASTE_REQUEST));

  entropy_core_component_event_register (layout,
					 entropy_core_gui_event_get
					 (ENTROPY_GUI_EVENT_AUTH_REQUEST));

  entropy_core_component_event_register (layout,
					 entropy_core_gui_event_get
					 (ENTROPY_GUI_EVENT_META_ALL_REQUEST));


  /*Etk related init */
  window = etk_window_new ();
  layout->gui_object = window;
  etk_signal_connect("key-down", ETK_OBJECT(window), ETK_CALLBACK(_entropy_etk_layout_key_down_cb), layout);
  
  gui->paned = etk_hpaned_new();
  

  etk_signal_connect ("delete-event", ETK_OBJECT (window),
		      ETK_CALLBACK (_etk_window_deleted_cb), layout);

  etk_window_title_set(ETK_WINDOW(window), "Entropy");
  etk_window_wmclass_set(ETK_WINDOW(window), "entropy", "Entropy");

  vbox = etk_vbox_new(ETK_FALSE,0);
  etk_container_add(ETK_CONTAINER(window), vbox);

  /*Tree init*/
  gui->tree = etk_tree_new();
  gui->tree_shell = etk_vbox_new(ETK_FALSE,0);
  etk_box_append(ETK_BOX(gui->tree_shell), gui->tree, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0); 

  etk_paned_child1_set(ETK_PANED(gui->paned), gui->tree_shell, ETK_FALSE);
  etk_tree_mode_set(ETK_TREE(gui->tree), ETK_TREE_MODE_TREE);
  col = etk_tree_col_new(ETK_TREE(gui->tree), _("Folders"), 60,0.0);
  etk_tree_col_model_add(col, etk_tree_model_image_new());
  etk_tree_col_model_add(col, etk_tree_model_text_new());   
  
  etk_tree_col_expand_set(col, ETK_TRUE);
  etk_tree_build(ETK_TREE(gui->tree));
  etk_widget_size_request_set(ETK_WIDGET(gui->tree), ENTROPY_ETK_WINDOW_PANE_DEFAULT_X, 50);

  /*Register to receive events related to the treeview config*/
  entropy_config_misc_callback_register("general.treeviewer", _entropy_layout_etk_simple_config_cb, gui);

  /*If we're configured not to show tree on start, don't show*/
  if (!entropy_config_misc_is_set("general.treeviewer")) {
	  entropy_etk_layout_tree_show(gui,0);
  } else {
	etk_paned_position_set(ETK_PANED(gui->paned), ENTROPY_ETK_WINDOW_PANE_DEFAULT_X);
  }

  /*LocalShell Init*/
  gui->localshell = etk_vbox_new(ETK_TRUE,0);
  etk_paned_child2_set(ETK_PANED(gui->paned), gui->localshell, ETK_TRUE);

  /*Trackback container init*/
  gui->trackback_shell = etk_vbox_new(ETK_TRUE,0);

  /*Popup init*/
   gui->popup = etk_menu_new();
   etk_signal_connect("row-clicked", ETK_OBJECT( gui->tree  ),
          ETK_CALLBACK(_etk_layout_row_clicked), layout);

   menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Delete this location"),
		   ETK_STOCK_DOCUMENT_OPEN, ETK_MENU_SHELL(gui->popup),NULL);
   etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(_etk_layout_location_delete_confirm_cb), layout);
   menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Add a new location"),
		   ETK_STOCK_DOCUMENT_OPEN, ETK_MENU_SHELL(gui->popup),NULL);
   

  for (structures = entropy_config_standard_structures_parse (layout, NULL); structures; ) {
	  structure = structures->data;
	  layout_etk_simple_add_header (layout,structure);
	  structures = structures->next;
  }

  /*Initialise the list view*/
  local = entropy_plugin_gui_get_by_name_toolkit(ENTROPY_TOOLKIT_ETK, "listviewer");
  if (local) {
	  local_plugin_init =
	      dlsym (local->dl_ref, "entropy_plugin_gui_instance_new");   
	  gui->list_viewer = (*local_plugin_init)(core, layout,NULL);
	  gui->list_viewer->plugin = local;
	  
	  if (entropy_config_misc_is_set("general.listviewer")) {
		  gui->list_viewer->active=1;
		  local_viewer_selected = 1;
		  etk_widget_show(gui->list_viewer->gui_object);
		  etk_box_append(ETK_BOX(gui->localshell), gui->list_viewer->gui_object, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0);
	  } else {
		   gui->list_viewer->active=0;
		   etk_widget_show(gui->list_viewer->gui_object);
	  }
   }

   /*Initialise the icon viewer*/
  /*Initialise the list view*/
  local = entropy_plugin_gui_get_by_name_toolkit(ENTROPY_TOOLKIT_ETK, "iconviewer");
  if (local) {
	  local_plugin_init =
	      dlsym (local->dl_ref, "entropy_plugin_gui_instance_new");   
	  gui->iconbox_viewer = (*local_plugin_init)(core, layout,NULL);
	  gui->iconbox_viewer->plugin = local;

	  if (entropy_config_misc_is_set("general.iconviewer")) {
		  gui->iconbox_viewer->active=1;
		  local_viewer_selected = 1;
		  etk_widget_show(gui->iconbox_viewer->gui_object);
		  etk_box_append(ETK_BOX(gui->localshell), gui->iconbox_viewer->gui_object, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0);
	  } else {
	  	gui->iconbox_viewer->active=0;
		etk_widget_show(gui->iconbox_viewer->gui_object);
	  }
   }

  /*Initialise the metadata plugin*/
  meta = entropy_plugins_type_get_first(ENTROPY_PLUGIN_GUI_COMPONENT, ENTROPY_PLUGIN_GUI_COMPONENT_INFO_PROVIDER);
  if (meta) {
	  local_plugin_init = 
	  dlsym(meta->dl_ref, "entropy_plugin_gui_instance_new");
	  meta_instance = (*local_plugin_init)(core,layout,NULL);
	  meta_instance->plugin = meta;
  }

  /*Initialise the hover viewer*/
  hover = entropy_plugins_type_get_first(ENTROPY_PLUGIN_GUI_COMPONENT, ENTROPY_PLUGIN_GUI_COMPONENT_HOVER_PROVIDER);
  if (hover) {
	  local_plugin_init = 
	  dlsym(hover->dl_ref, "entropy_plugin_gui_instance_new");
	  hover_instance = (*local_plugin_init)(core,layout,NULL);
	  hover_instance->plugin = hover;
  }


  /*Initialise the trackback*/
  trackback = entropy_plugin_gui_get_by_name_toolkit(ENTROPY_TOOLKIT_ETK, "trackback");
  if (trackback) {
	  local_plugin_init =
	      dlsym (trackback->dl_ref, "entropy_plugin_gui_instance_new");   
	  gui->trackback = (*local_plugin_init)(core, layout,NULL);
	  gui->trackback->plugin = trackback;
	  gui->trackback->active=1;

	  if (entropy_config_misc_is_set("general.trackback")) {
		  etk_box_append(ETK_BOX(gui->trackback_shell), gui->trackback->gui_object, ETK_BOX_START, ETK_BOX_NONE, 0);
	  }
	  entropy_config_misc_callback_register("general.trackback", _entropy_layout_etk_simple_config_cb, gui);
  }



  /*Menu setup*/
  menubar = etk_menu_bar_new();

  /*File menu*/
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("File"), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(menubar), NULL);
  menu = etk_menu_new();
  etk_menu_item_submenu_set(ETK_MENU_ITEM(menu_item), ETK_MENU(menu));
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Exit"), ETK_STOCK_SYSTEM_SHUTDOWN, ETK_MENU_SHELL(menu), NULL);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(etk_layout_simple_exit_cb), layout);
  
  /*Edit menu*/
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Edit"), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(menubar), NULL);
  menu = etk_menu_new();
  etk_menu_item_submenu_set(ETK_MENU_ITEM(menu_item), ETK_MENU(menu));
  
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Cut"), ETK_STOCK_EDIT_CUT, ETK_MENU_SHELL(menu), NULL);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(_entropy_layout_etk_cut_cb), layout);
  
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Copy"), ETK_STOCK_EDIT_COPY, ETK_MENU_SHELL(menu), NULL);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(_entropy_layout_etk_copy_cb), layout);
  
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Paste"), ETK_STOCK_EDIT_PASTE, ETK_MENU_SHELL(menu), NULL);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(_entropy_layout_etk_paste_cb), layout);
  
  
  /*Tools menu*/
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Tools"), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(menubar), NULL);
  menu = etk_menu_new();
  etk_menu_item_submenu_set(ETK_MENU_ITEM(menu_item), ETK_MENU(menu));
  
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Add Location"), ETK_STOCK_ADDRESS_BOOK_NEW, ETK_MENU_SHELL(menu), NULL);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(_location_add_cb), layout);
 
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("eFolder Wizard.."), ETK_STOCK_ADDRESS_BOOK_NEW, ETK_MENU_SHELL(menu), NULL);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(_entropy_etk_efolder_dialog_show_cb), layout);
  
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Program Associations.."), 
		  ETK_STOCK_EMBLEM_SYMBOLIC_LINK, ETK_MENU_SHELL(menu), NULL);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(etk_mime_dialog_cb), layout);

  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Options.."), 
		  ETK_STOCK_EMBLEM_SYMBOLIC_LINK, ETK_MENU_SHELL(menu), NULL);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(entropy_etk_options_dialog_cb), layout);
  
  /*View menu*/
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("View"), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(menubar), NULL);
  menu = etk_menu_new();
  etk_menu_item_submenu_set(ETK_MENU_ITEM(menu_item), ETK_MENU(menu));
  
  gui->tree_view_menu = _entropy_etk_menu_check_item_new(_("Tree View"), ETK_MENU_SHELL(menu));
  if (entropy_config_misc_is_set("general.treeviewer")) {
	etk_menu_item_check_active_set(ETK_MENU_ITEM_CHECK(gui->tree_view_menu),ETK_TRUE );
  }
  etk_signal_connect("activated", ETK_OBJECT(gui->tree_view_menu), ETK_CALLBACK(entropy_etk_layout_tree_cb), layout);

  menu_item = _entropy_etk_menu_check_item_new(_("Trackback view"), ETK_MENU_SHELL(menu));
  if (entropy_config_misc_is_set("general.trackback")) {
	etk_menu_item_check_active_set(ETK_MENU_ITEM_CHECK(menu_item), ETK_TRUE);
  }
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(entropy_etk_layout_trackback_cb), layout);


  _entropy_etk_menu_item_new(ETK_MENU_ITEM_SEPARATOR, NULL, 
		  ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(menu), NULL);

  menu_item = _entropy_etk_radio_item_new(_("List View (Alt-l)"), NULL, ETK_MENU_SHELL(menu));
  etk_object_data_set(ETK_OBJECT(menu_item), "VISUAL", gui->list_viewer);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(etk_local_viewer_cb), layout);
  if (entropy_config_misc_is_set("general.listviewer")) {
	  etk_menu_item_check_active_set(ETK_MENU_ITEM_CHECK(menu_item), ETK_TRUE);
  }

  
  menu_item = _entropy_etk_radio_item_new(_("Icon View (Alt-i)"), ETK_MENU_ITEM_RADIO(menu_item), ETK_MENU_SHELL(menu));
  etk_object_data_set(ETK_OBJECT(menu_item), "VISUAL", gui->iconbox_viewer);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(etk_local_viewer_cb), layout);
  if (entropy_config_misc_is_set("general.iconviewer")) {
	  etk_menu_item_check_active_set(ETK_MENU_ITEM_CHECK(menu_item), ETK_TRUE);
  }


  /*Debug menu*/
  /*menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Debug"), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(menubar), NULL); 
  menu = etk_menu_new();
  etk_menu_item_submenu_set(ETK_MENU_ITEM(menu_item), ETK_MENU(menu));
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("File Cache"), ETK_STOCK_PLACES_FOLDER_SAVED_SEARCH, ETK_MENU_SHELL(menu), NULL);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(etk_file_cache_dialog_cb), layout);*/
  
  /*Help menu*/
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("Help"), ETK_STOCK_NO_STOCK, ETK_MENU_SHELL(menubar), NULL);
  menu = etk_menu_new();
  etk_menu_item_submenu_set(ETK_MENU_ITEM(menu_item), ETK_MENU(menu));
  menu_item = _entropy_etk_menu_item_new(ETK_MENU_ITEM_NORMAL, _("About.."), ETK_STOCK_HELP_BROWSER, ETK_MENU_SHELL(menu), NULL);
  etk_signal_connect("activated", ETK_OBJECT(menu_item), ETK_CALLBACK(entropy_etk_about_dialog_cb), layout);

  etk_box_append(ETK_BOX(vbox), menubar, ETK_BOX_START, ETK_BOX_NONE, 0);
  etk_box_append(ETK_BOX(vbox), gui->trackback_shell, ETK_BOX_START, ETK_BOX_NONE, 0);
  etk_box_append(ETK_BOX(vbox), gui->paned, ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0);
  /*---------------------------*/

  gui->statusbar_box = etk_hbox_new(ETK_TRUE, 0);
  etk_box_append(ETK_BOX(vbox), gui->statusbar_box, ETK_BOX_START, ETK_BOX_NONE, 0);
  
  gui->statusbars[0] = etk_statusbar_new();
  etk_statusbar_has_resize_grip_set(ETK_STATUSBAR(gui->statusbars[0]), ETK_FALSE);
  etk_box_append(ETK_BOX(gui->statusbar_box), gui->statusbars[0], ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0);
   
  gui->statusbars[1] = etk_statusbar_new();
  etk_statusbar_has_resize_grip_set(ETK_STATUSBAR(gui->statusbars[1]), ETK_FALSE);
  etk_box_append(ETK_BOX(gui->statusbar_box), gui->statusbars[1], ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0);
   
  gui->statusbars[2] = etk_statusbar_new();
  etk_statusbar_has_resize_grip_set(ETK_STATUSBAR(gui->statusbars[2]), ETK_TRUE);
  etk_box_append(ETK_BOX(gui->statusbar_box), gui->statusbars[2], ETK_BOX_START, ETK_BOX_EXPAND_FILL, 0);
     
  etk_widget_show_all (window);

  /*Increment the window counter*/
  _etk_layout_window_count++;

  etk_window_resize(ETK_WINDOW(window), ENTROPY_ETK_WINDOW_WIDTH, ENTROPY_ETK_WINDOW_HEIGHT);

  return layout;
}