2014-02-12 12:56:20 -08:00
# ifdef HAVE_CONFIG_H
# include "config.h"
# endif
/* NOTE: Respecting header order is important for portability.
* Always put system first , then EFL , then your public header ,
* and finally your private one . */
# include <Ecore_Getopt.h>
# include <Elementary.h>
2014-02-14 15:50:25 -08:00
# include <Eio.h>
2014-02-12 12:56:20 -08:00
# include "Edi.h"
2014-12-01 14:54:17 -08:00
# include "edi_config.h"
2018-05-15 08:13:55 -07:00
# include "edi_theme.h"
2014-02-14 15:50:25 -08:00
# include "edi_filepanel.h"
2017-03-27 14:03:11 -07:00
# include "edi_file.h"
2018-11-25 09:05:16 -08:00
# include "edi_process.h"
2014-04-27 08:57:47 -07:00
# include "edi_logpanel.h"
# include "edi_consolepanel.h"
2017-03-30 15:03:19 -07:00
# include "edi_searchpanel.h"
2017-04-28 14:01:04 -07:00
# include "edi_debugpanel.h"
2017-05-13 15:29:46 -07:00
# include "edi_content_provider.h"
2014-09-13 08:48:16 -07:00
# include "mainview/edi_mainview.h"
2015-02-07 16:24:21 -08:00
# include "screens/edi_screens.h"
2017-05-30 00:30:24 -07:00
# include "screens/edi_file_screens.h"
2017-07-16 11:59:33 -07:00
# include "screens/edi_screens.h"
2014-02-12 12:56:20 -08:00
# include "edi_private.h"
2017-11-19 14:07:53 -08:00
# define MENU_ELLIPSIS(S) eina_slstr_printf("%s...", S)
2017-04-07 15:39:44 -07:00
int EDI_EVENT_TAB_CHANGED ;
int EDI_EVENT_FILE_CHANGED ;
2017-04-22 14:23:32 -07:00
int EDI_EVENT_FILE_SAVED ;
2017-04-07 15:39:44 -07:00
2014-11-29 11:06:02 -08:00
typedef struct _Edi_Panel_Slide_Effect
{
double max ;
Evas_Object * content ;
Eina_Bool expand ;
Eina_Bool left ;
} Edi_Panel_Slide_Effect ;
2019-12-28 09:30:26 -08:00
static Evas_Object * _edi_toolbar , * _edi_leftpanes , * _edi_bottompanes ;
2017-04-28 14:01:04 -07:00
static Evas_Object * _edi_logpanel , * _edi_consolepanel , * _edi_testpanel , * _edi_searchpanel , * _edi_taskspanel , * _edi_debugpanel ;
static Elm_Object_Item * _edi_logpanel_item , * _edi_consolepanel_item , * _edi_testpanel_item , * _edi_searchpanel_item , * _edi_taskspanel_item , * _edi_debugpanel_item ;
2014-11-22 07:56:16 -08:00
static Elm_Object_Item * _edi_selected_bottompanel ;
static Evas_Object * _edi_filepanel , * _edi_filepanel_icon ;
2017-09-20 16:54:01 -07:00
static Evas_Object * _edi_menu_undo , * _edi_menu_redo , * _edi_toolbar_undo , * _edi_toolbar_redo , * _edi_toolbar_build , * _edi_toolbar_test ;
2018-11-25 09:05:16 -08:00
static Evas_Object * _edi_menu_build , * _edi_menu_clean , * _edi_menu_test , * _edi_menu_run , * _edi_menu_terminate ;
2017-06-06 17:45:44 -07:00
static Evas_Object * _edi_menu_init , * _edi_menu_commit , * _edi_menu_push , * _edi_menu_pull , * _edi_menu_status , * _edi_menu_stash ;
2017-04-22 14:23:32 -07:00
static Evas_Object * _edi_menu_save , * _edi_toolbar_save ;
2017-09-02 03:20:49 -07:00
static Evas_Object * _edi_main_win , * _edi_main_box ;
2019-12-28 09:30:26 -08:00
static Evas_Object * _edi_toolbar_run , * _edi_toolbar_terminate , * _edi_toolbar_hbx , * _edi_toolbar_vbx , * _edi_toolbar_main_box ;
2014-12-21 15:32:14 -08:00
int _edi_log_dom = - 1 ;
2014-03-14 06:43:34 -07:00
2018-11-25 09:05:16 -08:00
static void
_edi_active_process_icons_set ( Eina_Bool active )
{
if ( active )
{
elm_object_disabled_set ( _edi_toolbar_run , EINA_TRUE ) ;
elm_object_disabled_set ( _edi_toolbar_terminate , EINA_FALSE ) ;
elm_object_item_disabled_set ( _edi_menu_run , EINA_TRUE ) ;
elm_object_item_disabled_set ( _edi_menu_terminate , EINA_FALSE ) ;
}
else
{
elm_object_disabled_set ( _edi_toolbar_run , EINA_FALSE ) ;
elm_object_disabled_set ( _edi_toolbar_terminate , EINA_TRUE ) ;
elm_object_item_disabled_set ( _edi_menu_run , EINA_FALSE ) ;
elm_object_item_disabled_set ( _edi_menu_terminate , EINA_TRUE ) ;
}
}
static Eina_Bool
_edi_active_process_check_cb ( EINA_UNUSED void * data )
{
Edi_Proc_Stats * stats ;
pid_t pid ;
// Check debugpanel state.
edi_debugpanel_active_check ( ) ;
pid = edi_exe_project_pid_get ( ) ;
if ( pid = = - 1 )
{
_edi_active_process_icons_set ( EINA_FALSE ) ;
return ECORE_CALLBACK_RENEW ;
}
stats = edi_process_stats_by_pid ( pid ) ;
if ( ! stats )
{
2019-12-26 10:00:55 -08:00
// Our process is not running, reset PID.
2018-11-25 09:05:16 -08:00
edi_exe_project_pid_reset ( ) ;
_edi_active_process_icons_set ( EINA_FALSE ) ;
return ECORE_CALLBACK_RENEW ;
}
free ( stats ) ;
_edi_active_process_icons_set ( EINA_TRUE ) ;
return ECORE_CALLBACK_RENEW ;
}
2015-01-15 14:56:08 -08:00
2014-02-15 15:17:40 -08:00
static void
2014-03-13 11:31:24 -07:00
_edi_file_open_cb ( const char * path , const char * type , Eina_Bool newwin )
2014-02-15 15:17:40 -08:00
{
2014-03-16 09:01:35 -07:00
Edi_Path_Options * options ;
2017-09-02 03:20:49 -07:00
const char * title , * message ;
2014-03-16 09:01:35 -07:00
2015-01-15 14:56:08 -08:00
if ( path = = NULL )
{
2017-09-11 13:06:22 -07:00
title = _ ( " File path required " ) ;
message = _ ( " Please choose a file from the list. " ) ;
2017-09-02 03:20:49 -07:00
edi_screens_message ( _edi_main_win , title , message ) ;
2015-01-15 14:56:08 -08:00
return ;
}
2014-03-16 09:01:35 -07:00
options = edi_path_options_create ( path ) ;
options - > type = type ;
2014-02-26 00:17:44 -08:00
if ( type = = NULL )
INF ( " Opening %s " , path ) ;
else
INF ( " Opening %s as %s " , path , type ) ;
2014-02-15 15:17:40 -08:00
2014-03-13 11:31:24 -07:00
if ( newwin )
2014-03-16 09:01:35 -07:00
edi_mainview_open_window ( options ) ;
2014-03-13 11:31:24 -07:00
else
2014-03-16 09:01:35 -07:00
edi_mainview_open ( options ) ;
2014-02-25 23:28:24 -08:00
}
2014-12-03 15:52:12 -08:00
static Evas_Object *
_edi_panel_tab_for_index ( int index )
{
if ( index = = 1 )
return _edi_consolepanel ;
if ( index = = 2 )
return _edi_testpanel ;
2017-03-30 15:03:19 -07:00
if ( index = = 3 )
return _edi_searchpanel ;
2017-04-05 11:15:47 -07:00
if ( index = = 4 )
return _edi_taskspanel ;
2017-04-28 14:01:04 -07:00
if ( index = = 5 )
return _edi_debugpanel ;
2014-12-03 15:52:12 -08:00
return _edi_logpanel ;
}
static void
_edi_panel_size_save ( Eina_Bool left )
{
double size ;
Eina_Bool open ;
if ( left )
size = elm_panes_content_left_size_get ( _edi_leftpanes ) ;
else
size = elm_panes_content_right_size_get ( _edi_bottompanes ) ;
2019-12-26 10:00:55 -08:00
2014-12-03 15:52:12 -08:00
open = ( size ! = 0.0 ) ;
if ( left )
{
2015-05-16 01:56:39 -07:00
_edi_project_config - > gui . leftopen = open ;
2014-12-03 15:52:12 -08:00
if ( open )
2015-05-16 01:56:39 -07:00
_edi_project_config - > gui . leftsize = size ;
2014-12-03 15:52:12 -08:00
}
else
{
2015-05-16 01:56:39 -07:00
_edi_project_config - > gui . bottomopen = open ;
2014-12-03 15:52:12 -08:00
if ( open )
2015-05-16 01:56:39 -07:00
_edi_project_config - > gui . bottomsize = size ;
2014-12-03 15:52:12 -08:00
}
2015-05-16 01:56:39 -07:00
_edi_project_config_save ( ) ;
2014-12-03 15:52:12 -08:00
}
static void
_edi_panel_save_tab ( int index )
{
2015-05-16 01:56:39 -07:00
_edi_project_config - > gui . bottomtab = index ;
_edi_project_config_save ( ) ;
2014-12-03 15:52:12 -08:00
}
2014-11-29 11:06:02 -08:00
static void
_edi_slide_panel ( Elm_Transit_Effect * effect , Elm_Transit * transit , double progress )
{
Edi_Panel_Slide_Effect * slide ;
Evas_Object * obj ;
2014-11-29 18:45:49 -08:00
double position , weight ;
2014-11-29 11:06:02 -08:00
const Eina_List * item ;
const Eina_List * objs ;
if ( ! effect ) return ;
slide = ( Edi_Panel_Slide_Effect * ) effect ;
objs = elm_transit_objects_get ( transit ) ;
2014-11-29 18:45:49 -08:00
if ( slide - > left )
position = elm_panes_content_left_size_get ( eina_list_nth ( objs , 0 ) ) ;
else
position = elm_panes_content_right_size_get ( eina_list_nth ( objs , 0 ) ) ;
2014-11-29 11:06:02 -08:00
if ( slide - > expand )
weight = progress * slide - > max ;
else
2014-11-29 18:45:49 -08:00
weight = ( 1 - progress ) * position ;
2014-11-29 11:06:02 -08:00
if ( slide - > left )
EINA_LIST_FOREACH ( objs , item , obj )
elm_panes_content_left_size_set ( obj , weight ) ;
else
EINA_LIST_FOREACH ( objs , item , obj )
elm_panes_content_right_size_set ( obj , weight ) ;
}
static void
_edi_slide_panel_free ( Elm_Transit_Effect * effect , Elm_Transit * transit EINA_UNUSED )
{
Edi_Panel_Slide_Effect * slide ;
slide = ( Edi_Panel_Slide_Effect * ) effect ;
if ( ! slide - > expand )
evas_object_hide ( slide - > content ) ;
free ( slide ) ;
2014-12-03 15:52:12 -08:00
_edi_panel_size_save ( slide - > left ) ;
2014-11-29 11:06:02 -08:00
}
static void
_edi_slide_panel_new ( Evas_Object * panel , Evas_Object * content , double max ,
Eina_Bool expand , Eina_Bool left )
{
Edi_Panel_Slide_Effect * slide ;
Elm_Transit * trans ;
slide = malloc ( sizeof ( Edi_Panel_Slide_Effect ) ) ;
slide - > max = max ;
slide - > content = content ;
slide - > expand = expand ;
slide - > left = left ;
if ( slide - > expand )
evas_object_show ( slide - > content ) ;
/* Adding Transit */
trans = elm_transit_add ( ) ;
2014-11-29 18:45:49 -08:00
elm_transit_tween_mode_set ( trans , ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL ) ;
2014-11-29 11:06:02 -08:00
elm_transit_object_add ( trans , panel ) ;
elm_transit_effect_add ( trans , _edi_slide_panel , slide , _edi_slide_panel_free ) ;
2014-11-29 18:45:49 -08:00
elm_transit_duration_set ( trans , 0.33 ) ;
2014-11-29 11:06:02 -08:00
elm_transit_go ( trans ) ;
}
2014-03-14 06:43:34 -07:00
static void
2014-11-22 07:56:16 -08:00
_edi_toggle_file_panel ( void * data , Evas_Object * obj EINA_UNUSED , void * event_info EINA_UNUSED )
2014-03-14 06:43:34 -07:00
{
2014-11-22 07:56:16 -08:00
Evas_Object * panel ;
double size ;
panel = ( Evas_Object * ) data ;
size = elm_panes_content_left_size_get ( _edi_leftpanes ) ;
if ( size = = 0.0 )
{
2017-06-29 14:25:26 -07:00
elm_icon_standard_set ( _edi_filepanel_icon , " go-previous " ) ;
2015-05-16 01:56:39 -07:00
_edi_slide_panel_new ( _edi_leftpanes , panel , _edi_project_config - > gui . leftsize , EINA_TRUE , EINA_TRUE ) ;
2014-11-22 07:56:16 -08:00
}
else
{
2017-06-29 14:25:26 -07:00
elm_icon_standard_set ( _edi_filepanel_icon , " go-next " ) ;
2015-05-16 01:56:39 -07:00
_edi_slide_panel_new ( _edi_leftpanes , panel , _edi_project_config - > gui . leftsize , EINA_FALSE , EINA_TRUE ) ;
2014-11-22 07:56:16 -08:00
}
}
static void
_edi_toggle_panel ( void * data , Evas_Object * obj , void * event_info )
{
2014-12-03 15:52:12 -08:00
int index , c ;
2014-11-22 07:56:16 -08:00
double size ;
Elm_Object_Item * item ;
Evas_Object * panel ;
2014-12-03 15:52:12 -08:00
index = atoi ( ( char * ) data ) ;
panel = _edi_panel_tab_for_index ( index ) ;
2014-11-22 07:56:16 -08:00
item = ( Elm_Object_Item * ) event_info ;
2014-11-29 10:16:57 -08:00
2014-11-22 07:56:16 -08:00
if ( obj )
elm_object_focus_set ( obj , EINA_FALSE ) ;
2017-04-28 14:01:04 -07:00
for ( c = 0 ; c < = 5 ; c + + )
2014-12-03 15:52:12 -08:00
if ( c ! = index )
evas_object_hide ( _edi_panel_tab_for_index ( c ) ) ;
2014-11-22 07:56:16 -08:00
if ( item = = _edi_selected_bottompanel )
{
2019-12-26 07:36:29 -08:00
elm_toolbar_item_icon_set ( item , edi_theme_icon_path_get ( " go-up " ) ) ;
2014-11-22 07:56:16 -08:00
2015-05-16 01:56:39 -07:00
_edi_slide_panel_new ( _edi_bottompanes , panel , _edi_project_config - > gui . bottomsize , EINA_FALSE , EINA_FALSE ) ;
2014-11-22 07:56:16 -08:00
_edi_selected_bottompanel = NULL ;
}
else
{
if ( _edi_selected_bottompanel )
2019-12-26 06:24:42 -08:00
elm_toolbar_item_icon_set ( _edi_selected_bottompanel , edi_theme_icon_path_get ( " go-up " ) ) ;
elm_toolbar_item_icon_set ( item , edi_theme_icon_path_get ( " go-down " ) ) ;
2014-11-22 07:56:16 -08:00
size = elm_panes_content_right_size_get ( _edi_bottompanes ) ;
if ( size = = 0.0 )
2015-05-16 01:56:39 -07:00
_edi_slide_panel_new ( _edi_bottompanes , panel , _edi_project_config - > gui . bottomsize , EINA_TRUE , EINA_FALSE ) ;
2014-11-29 11:06:02 -08:00
else
evas_object_show ( panel ) ;
2014-11-22 07:56:16 -08:00
_edi_selected_bottompanel = item ;
}
2014-11-29 10:16:57 -08:00
elm_toolbar_item_selected_set ( item , EINA_FALSE ) ;
2014-12-03 15:52:12 -08:00
_edi_panel_save_tab ( index ) ;
}
static void
_edi_panel_dragged_cb ( void * data , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
_edi_panel_size_save ( data = = _edi_filepanel ) ;
2014-03-14 06:43:34 -07:00
}
2015-01-10 09:43:12 -08:00
void
2014-12-03 15:52:12 -08:00
edi_consolepanel_show ( )
2014-04-27 08:57:47 -07:00
{
2014-11-29 10:24:56 -08:00
if ( _edi_selected_bottompanel ! = _edi_consolepanel_item )
elm_toolbar_item_selected_set ( _edi_consolepanel_item , EINA_TRUE ) ;
2014-04-27 08:57:47 -07:00
}
2015-01-10 09:43:12 -08:00
void
2014-12-03 15:52:12 -08:00
edi_testpanel_show ( )
2014-11-18 13:11:10 -08:00
{
2014-11-29 10:24:56 -08:00
if ( _edi_selected_bottompanel ! = _edi_testpanel_item )
elm_toolbar_item_selected_set ( _edi_testpanel_item , EINA_TRUE ) ;
2014-11-18 13:11:10 -08:00
}
2017-03-30 15:03:19 -07:00
void
edi_searchpanel_show ( )
{
if ( _edi_selected_bottompanel ! = _edi_searchpanel_item )
elm_toolbar_item_selected_set ( _edi_searchpanel_item , EINA_TRUE ) ;
}
2017-04-05 11:15:47 -07:00
void
edi_taskspanel_show ( )
{
if ( _edi_selected_bottompanel ! = _edi_taskspanel_item )
elm_toolbar_item_selected_set ( _edi_taskspanel_item , EINA_TRUE ) ;
}
2017-04-28 14:01:04 -07:00
void
edi_debugpanel_show ( )
{
if ( _edi_selected_bottompanel ! = _edi_debugpanel_item )
elm_toolbar_item_selected_set ( _edi_debugpanel_item , EINA_TRUE ) ;
}
2017-06-18 14:52:02 -07:00
static void
_edi_toolbar_separator_add ( Evas_Object * tb )
{
Evas_Object * sep ;
sep = elm_toolbar_item_append ( tb , NULL , NULL , NULL , 0 ) ;
elm_toolbar_item_separator_set ( sep , EINA_TRUE ) ;
}
2014-02-12 15:02:09 -08:00
static Evas_Object *
2014-02-16 11:54:06 -08:00
edi_content_setup ( Evas_Object * win , const char * path )
2014-02-12 15:02:09 -08:00
{
2018-09-04 08:10:36 -07:00
Evas_Object * filepane , * logpane , * logpanels , * scroller , * content_out , * content_in , * tb ;
2017-07-23 13:54:47 -07:00
Evas_Object * icon , * button , * mainview ;
2014-02-12 15:02:09 -08:00
2014-11-22 07:56:16 -08:00
filepane = elm_panes_add ( win ) ;
evas_object_size_hint_weight_set ( filepane , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
2014-11-22 08:52:14 -08:00
evas_object_size_hint_align_set ( filepane , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
logpane = elm_panes_add ( win ) ;
2014-11-22 07:56:16 -08:00
elm_panes_horizontal_set ( logpane , EINA_TRUE ) ;
evas_object_size_hint_weight_set ( logpane , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
2014-11-22 08:52:14 -08:00
evas_object_size_hint_align_set ( logpane , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
2014-02-12 15:02:09 -08:00
2014-11-22 07:56:16 -08:00
_edi_filepanel = elm_box_add ( win ) ;
_edi_logpanel = elm_box_add ( win ) ;
_edi_consolepanel = elm_box_add ( win ) ;
_edi_testpanel = elm_box_add ( win ) ;
2017-03-30 15:03:19 -07:00
_edi_searchpanel = elm_box_add ( win ) ;
2017-04-05 11:15:47 -07:00
_edi_taskspanel = elm_box_add ( win ) ;
2017-04-28 14:01:04 -07:00
_edi_debugpanel = elm_box_add ( win ) ;
2014-02-15 15:17:40 -08:00
2014-03-14 06:43:34 -07:00
// add main content
content_out = elm_box_add ( win ) ;
elm_box_horizontal_set ( content_out , EINA_FALSE ) ;
2014-11-22 08:52:14 -08:00
evas_object_size_hint_weight_set ( content_out , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
2014-03-14 06:43:34 -07:00
evas_object_size_hint_align_set ( content_out , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
content_in = elm_box_add ( content_out ) ;
elm_box_horizontal_set ( content_in , EINA_TRUE ) ;
evas_object_size_hint_weight_set ( content_in , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( content_in , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
2014-11-22 07:56:16 -08:00
icon = elm_icon_add ( content_in ) ;
2015-05-16 01:56:39 -07:00
if ( _edi_project_config - > gui . leftopen )
2017-06-29 14:25:26 -07:00
elm_icon_standard_set ( icon , " go-previous " ) ;
2014-12-03 15:52:12 -08:00
else
2017-06-29 14:25:26 -07:00
elm_icon_standard_set ( icon , " go-next " ) ;
2014-03-14 06:43:34 -07:00
button = elm_button_add ( content_in ) ;
2014-11-22 07:56:16 -08:00
elm_object_part_content_set ( button , " icon " , icon ) ;
elm_object_focus_allow_set ( button , EINA_FALSE ) ;
_edi_filepanel_icon = icon ;
2014-03-14 06:43:34 -07:00
evas_object_smart_callback_add ( button , " clicked " ,
2014-11-22 07:56:16 -08:00
_edi_toggle_file_panel , _edi_filepanel ) ;
2014-03-14 06:43:34 -07:00
evas_object_size_hint_align_set ( button , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
elm_box_pack_end ( content_in , button ) ;
evas_object_show ( button ) ;
2017-07-23 13:54:47 -07:00
mainview = elm_box_add ( content_in ) ;
evas_object_size_hint_weight_set ( mainview , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( mainview , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
evas_object_show ( mainview ) ;
elm_box_pack_end ( content_in , mainview ) ;
edi_mainview_add ( mainview , win ) ;
2014-11-22 08:52:14 -08:00
elm_object_part_content_set ( filepane , " right " , content_in ) ;
evas_object_show ( filepane ) ;
2014-11-22 07:56:16 -08:00
_edi_leftpanes = filepane ;
2018-09-04 08:10:36 -07:00
elm_box_pack_end ( content_out , filepane ) ;
scroller = elm_scroller_add ( win ) ;
evas_object_size_hint_weight_set ( scroller , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( scroller , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
evas_object_show ( scroller ) ;
elm_object_content_set ( scroller , content_out ) ;
elm_object_part_content_set ( logpane , " top " , scroller ) ;
2014-02-12 15:02:09 -08:00
2014-02-25 20:32:12 -08:00
// add file list
2014-11-22 07:56:16 -08:00
evas_object_size_hint_weight_set ( _edi_filepanel , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
2014-03-14 06:43:34 -07:00
evas_object_size_hint_align_set ( _edi_filepanel , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
2015-05-16 01:56:39 -07:00
if ( _edi_project_config - > gui . leftopen )
elm_panes_content_left_size_set ( filepane , _edi_project_config - > gui . leftsize ) ;
2014-12-03 15:52:12 -08:00
else
elm_panes_content_left_size_set ( filepane , 0.0 ) ;
evas_object_smart_callback_add ( filepane , " unpress " , _edi_panel_dragged_cb , _edi_filepanel ) ;
2014-03-14 02:41:09 -07:00
2014-03-14 06:43:34 -07:00
edi_filepanel_add ( _edi_filepanel , win , path , _edi_file_open_cb ) ;
2014-11-22 07:56:16 -08:00
elm_object_part_content_set ( filepane , " left " , _edi_filepanel ) ;
2014-03-14 06:43:34 -07:00
evas_object_show ( _edi_filepanel ) ;
2014-02-25 20:32:12 -08:00
2014-11-22 07:56:16 -08:00
// add lower panel buttons
2014-04-27 08:57:47 -07:00
tb = elm_toolbar_add ( content_out ) ;
evas_object_size_hint_weight_set ( tb , EVAS_HINT_EXPAND , 0.0 ) ;
evas_object_size_hint_align_set ( tb , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
elm_toolbar_homogeneous_set ( tb , EINA_FALSE ) ;
elm_toolbar_align_set ( tb , 1.0 ) ;
2019-12-26 10:00:55 -08:00
elm_toolbar_icon_size_set ( tb , 24 * elm_config_scale_get ( ) ) ;
2014-11-22 07:56:16 -08:00
elm_object_style_set ( tb , " item_horizontal " ) ;
elm_object_focus_allow_set ( tb , EINA_FALSE ) ;
2014-04-27 08:57:47 -07:00
elm_toolbar_shrink_mode_set ( tb , ELM_TOOLBAR_SHRINK_SCROLL ) ;
2014-11-22 07:56:16 -08:00
elm_toolbar_select_mode_set ( tb , ELM_OBJECT_SELECT_MODE_DEFAULT ) ;
2014-04-27 08:57:47 -07:00
elm_box_pack_end ( content_out , tb ) ;
evas_object_show ( tb ) ;
2017-06-18 14:52:02 -07:00
_edi_toolbar_separator_add ( tb ) ;
2019-12-26 06:24:42 -08:00
_edi_logpanel_item = elm_toolbar_item_append ( tb , edi_theme_icon_path_get ( " go-up " ) , _ ( " Logs " ) ,
2014-12-03 15:52:12 -08:00
_edi_toggle_panel , " 0 " ) ;
2017-06-18 14:52:02 -07:00
_edi_toolbar_separator_add ( tb ) ;
2019-12-26 06:24:42 -08:00
_edi_consolepanel_item = elm_toolbar_item_append ( tb , edi_theme_icon_path_get ( " go-up " ) , _ ( " Console " ) ,
2014-12-03 15:52:12 -08:00
_edi_toggle_panel , " 1 " ) ;
2017-06-18 14:52:02 -07:00
_edi_toolbar_separator_add ( tb ) ;
2019-12-26 06:24:42 -08:00
_edi_testpanel_item = elm_toolbar_item_append ( tb , edi_theme_icon_path_get ( " go-up " ) , _ ( " Tests " ) ,
2014-12-03 15:52:12 -08:00
_edi_toggle_panel , " 2 " ) ;
2017-06-18 14:52:02 -07:00
_edi_toolbar_separator_add ( tb ) ;
2019-12-26 06:24:42 -08:00
_edi_searchpanel_item = elm_toolbar_item_append ( tb , edi_theme_icon_path_get ( " go-up " ) , _ ( " Search " ) ,
2017-03-30 15:03:19 -07:00
_edi_toggle_panel , " 3 " ) ;
2017-06-18 14:52:02 -07:00
_edi_toolbar_separator_add ( tb ) ;
2019-12-26 06:24:42 -08:00
_edi_taskspanel_item = elm_toolbar_item_append ( tb , edi_theme_icon_path_get ( " go-up " ) , _ ( " Tasks " ) ,
2017-04-05 11:15:47 -07:00
_edi_toggle_panel , " 4 " ) ;
2017-06-18 14:52:02 -07:00
_edi_toolbar_separator_add ( tb ) ;
2019-12-26 06:24:42 -08:00
_edi_debugpanel_item = elm_toolbar_item_append ( tb , edi_theme_icon_path_get ( " go-up " ) , _ ( " Debug " ) ,
2017-04-28 14:01:04 -07:00
_edi_toggle_panel , " 5 " ) ;
2017-06-18 14:52:02 -07:00
_edi_toolbar_separator_add ( tb ) ;
2014-04-27 08:57:47 -07:00
2014-11-22 07:56:16 -08:00
// add lower panel panes
logpanels = elm_table_add ( logpane ) ;
evas_object_size_hint_weight_set ( _edi_logpanel , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
2014-03-14 06:43:34 -07:00
evas_object_size_hint_align_set ( _edi_logpanel , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
2014-03-14 02:41:09 -07:00
2014-03-14 06:43:34 -07:00
edi_logpanel_add ( _edi_logpanel ) ;
2014-11-22 07:56:16 -08:00
elm_table_pack ( logpanels , _edi_logpanel , 0 , 0 , 1 , 1 ) ;
2014-03-14 06:43:34 -07:00
2014-11-22 07:56:16 -08:00
evas_object_size_hint_weight_set ( _edi_consolepanel , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
2014-04-27 08:57:47 -07:00
evas_object_size_hint_align_set ( _edi_consolepanel , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
edi_consolepanel_add ( _edi_consolepanel ) ;
2014-11-22 07:56:16 -08:00
elm_table_pack ( logpanels , _edi_consolepanel , 0 , 0 , 1 , 1 ) ;
2014-04-27 08:57:47 -07:00
2014-11-22 07:56:16 -08:00
evas_object_size_hint_weight_set ( _edi_testpanel , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
2014-11-18 13:11:10 -08:00
evas_object_size_hint_align_set ( _edi_testpanel , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
edi_testpanel_add ( _edi_testpanel ) ;
2014-11-22 07:56:16 -08:00
elm_table_pack ( logpanels , _edi_testpanel , 0 , 0 , 1 , 1 ) ;
2017-03-30 15:03:19 -07:00
evas_object_size_hint_weight_set ( _edi_searchpanel , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( _edi_searchpanel , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
edi_searchpanel_add ( _edi_searchpanel ) ;
elm_table_pack ( logpanels , _edi_searchpanel , 0 , 0 , 1 , 1 ) ;
2017-04-05 11:15:47 -07:00
evas_object_size_hint_weight_set ( _edi_taskspanel , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( _edi_taskspanel , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
edi_taskspanel_add ( _edi_taskspanel ) ;
elm_table_pack ( logpanels , _edi_taskspanel , 0 , 0 , 1 , 1 ) ;
2017-04-28 14:01:04 -07:00
edi_debugpanel_add ( _edi_debugpanel ) ;
elm_table_pack ( logpanels , _edi_debugpanel , 0 , 0 , 1 , 1 ) ;
evas_object_size_hint_weight_set ( _edi_debugpanel , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( _edi_debugpanel , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
2014-11-22 07:56:16 -08:00
elm_object_part_content_set ( logpane , " bottom " , logpanels ) ;
2017-03-30 15:03:19 -07:00
2015-05-16 01:56:39 -07:00
if ( _edi_project_config - > gui . bottomopen )
2014-12-03 15:52:12 -08:00
{
2015-05-16 01:56:39 -07:00
elm_panes_content_right_size_set ( logpane , _edi_project_config - > gui . bottomsize ) ;
if ( _edi_project_config - > gui . bottomtab = = 1 )
2014-12-08 13:03:26 -08:00
{
2019-12-26 06:24:42 -08:00
elm_toolbar_item_icon_set ( _edi_consolepanel_item , edi_theme_icon_path_get ( " go-down " ) ) ;
2014-12-08 13:03:26 -08:00
_edi_selected_bottompanel = _edi_consolepanel_item ;
}
2015-05-16 01:56:39 -07:00
else if ( _edi_project_config - > gui . bottomtab = = 2 )
2014-12-08 13:03:26 -08:00
{
2019-12-26 06:24:42 -08:00
elm_toolbar_item_icon_set ( _edi_testpanel_item , edi_theme_icon_path_get ( " go-down " ) ) ;
2014-12-08 13:03:26 -08:00
_edi_selected_bottompanel = _edi_testpanel_item ;
}
2017-03-30 15:03:19 -07:00
else if ( _edi_project_config - > gui . bottomtab = = 3 )
{
2019-12-26 06:24:42 -08:00
elm_toolbar_item_icon_set ( _edi_searchpanel_item , edi_theme_icon_path_get ( " go-down " ) ) ;
2017-03-30 15:03:19 -07:00
_edi_selected_bottompanel = _edi_searchpanel_item ;
}
2017-04-05 11:15:47 -07:00
else if ( _edi_project_config - > gui . bottomtab = = 4 )
{
2019-12-26 06:24:42 -08:00
elm_toolbar_item_icon_set ( _edi_taskspanel_item , edi_theme_icon_path_get ( " go-down " ) ) ;
2017-04-05 11:15:47 -07:00
_edi_selected_bottompanel = _edi_taskspanel_item ;
}
2017-04-28 14:01:04 -07:00
else if ( _edi_project_config - > gui . bottomtab = = 5 )
{
2019-12-26 06:24:42 -08:00
elm_toolbar_item_icon_set ( _edi_debugpanel_item , edi_theme_icon_path_get ( " go-down " ) ) ;
2017-04-28 14:01:04 -07:00
_edi_selected_bottompanel = _edi_debugpanel_item ;
}
2014-12-03 15:52:12 -08:00
else
2014-12-08 13:03:26 -08:00
{
2019-12-26 06:24:42 -08:00
elm_toolbar_item_icon_set ( _edi_logpanel_item , edi_theme_icon_path_get ( " go-down " ) ) ;
2014-12-08 13:03:26 -08:00
_edi_selected_bottompanel = _edi_logpanel_item ;
}
2014-12-03 15:52:12 -08:00
}
else
elm_panes_content_right_size_set ( logpane , 0.0 ) ;
2015-05-16 01:56:39 -07:00
if ( _edi_project_config - > gui . bottomopen )
evas_object_show ( _edi_panel_tab_for_index ( _edi_project_config - > gui . bottomtab ) ) ;
2014-12-03 15:52:12 -08:00
evas_object_smart_callback_add ( logpane , " unpress " , _edi_panel_dragged_cb , NULL ) ;
2014-11-22 07:56:16 -08:00
evas_object_show ( logpane ) ;
_edi_bottompanes = logpane ;
return logpane ;
2014-02-12 15:02:09 -08:00
}
2017-06-06 17:45:44 -07:00
static void
_edi_icon_update ( )
{
Eina_Bool modified , can_scm , can_remote , can_undo , can_redo ;
can_undo = edi_mainview_can_undo ( ) ;
can_redo = edi_mainview_can_redo ( ) ;
can_scm = edi_scm_enabled ( ) ;
can_remote = can_scm & & edi_scm_remote_enabled ( ) ;
modified = edi_mainview_modified ( ) ;
elm_object_item_disabled_set ( _edi_menu_save , ! modified ) ;
elm_object_disabled_set ( _edi_toolbar_save , ! modified ) ;
elm_object_item_disabled_set ( _edi_menu_undo , ! can_undo ) ;
elm_object_item_disabled_set ( _edi_menu_redo , ! can_redo ) ;
elm_object_disabled_set ( _edi_toolbar_undo , ! can_undo ) ;
elm_object_disabled_set ( _edi_toolbar_redo , ! can_redo ) ;
elm_object_item_disabled_set ( _edi_menu_init , can_scm ) ;
elm_object_item_disabled_set ( _edi_menu_push , ! can_remote ) ;
elm_object_item_disabled_set ( _edi_menu_pull , ! can_remote ) ;
elm_object_item_disabled_set ( _edi_menu_status , ! can_scm ) ;
elm_object_item_disabled_set ( _edi_menu_commit , ! can_scm ) ;
elm_object_item_disabled_set ( _edi_menu_stash , ! can_scm ) ;
}
2017-04-28 13:16:47 -07:00
void
edi_launcher_config_missing ( )
2015-05-31 04:13:31 -07:00
{
2017-09-02 03:20:49 -07:00
const char * title , * message ;
2015-05-31 04:13:31 -07:00
2017-09-11 13:06:22 -07:00
title = _ ( " Unable to launch " ) ;
message = _ ( " No launch binary found, please configure in Settings. " ) ;
2015-05-31 04:13:31 -07:00
2018-12-17 06:15:41 -08:00
edi_screens_settings_message ( _edi_main_win , EDI_SETTINGS_TAB_BUILDS , title , message ) ;
2015-05-31 04:13:31 -07:00
}
2017-11-08 13:26:42 -08:00
void
edi_debug_exe_missing ( void )
{
const char * title , * message ;
title = _ ( " Unable to launch debugger " ) ;
message = _ ( " No debug binary found, please check system configuration and Settings. " ) ;
2018-12-17 06:15:41 -08:00
edi_screens_settings_message ( _edi_main_win , EDI_SETTINGS_TAB_BUILDS , title , message ) ;
2017-11-08 13:26:42 -08:00
}
2017-06-06 17:45:44 -07:00
static void
_edi_project_credentials_missing ( )
{
2017-09-02 03:20:49 -07:00
const char * title , * message ;
2017-06-06 17:45:44 -07:00
2017-09-11 13:06:22 -07:00
title = _ ( " Missing user information " ) ;
message = _ ( " No user information found, please configure in Settings. " ) ;
2017-06-06 17:45:44 -07:00
2018-12-17 06:15:41 -08:00
edi_screens_settings_message ( _edi_main_win , EDI_SETTINGS_TAB_PROJECT , title , message ) ;
2017-06-06 17:45:44 -07:00
}
static Eina_Bool
_edi_project_credentials_check ( void )
{
2017-12-30 13:59:56 -08:00
Edi_Scm_Engine * eng ;
eng = edi_scm_engine_get ( ) ;
2018-05-13 04:50:21 -07:00
2018-05-13 16:25:34 -07:00
if ( ( ! _edi_project_config - > user_fullname | | ! _edi_project_config - > user_fullname [ 0 ] ) & &
( ! eng | | ! eng - > remote_name_get ( ) ) )
2017-06-06 17:45:44 -07:00
return EINA_FALSE ;
2018-05-13 16:25:34 -07:00
if ( ( ! _edi_project_config - > user_email | | ! _edi_project_config - > user_email [ 0 ] ) & &
( ! eng | | ! eng - > remote_email_get ( ) ) )
2017-06-06 17:45:44 -07:00
return EINA_FALSE ;
return EINA_TRUE ;
}
2014-02-12 15:02:09 -08:00
static void
2017-03-27 14:03:11 -07:00
_tb_new_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
2014-02-12 15:02:09 -08:00
{
2017-03-27 14:03:11 -07:00
const char * path , * selected ;
2016-01-21 12:05:43 -08:00
2015-07-17 10:30:25 -07:00
selected = edi_filepanel_selected_path_get ( _edi_filepanel ) ;
if ( selected & & ecore_file_is_dir ( selected ) )
2017-03-27 14:03:11 -07:00
path = selected ;
2015-07-17 10:30:25 -07:00
else
2017-03-27 14:03:11 -07:00
path = edi_project_get ( ) ;
2014-03-31 14:24:56 -07:00
2015-05-18 16:01:56 -07:00
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( obj ) , EINA_FALSE ) ;
2017-05-30 00:30:24 -07:00
edi_file_screens_create_file ( _edi_main_win , path ) ;
2015-05-18 16:01:56 -07:00
}
2014-03-31 14:24:56 -07:00
static void
_tb_save_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
{
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( obj ) , EINA_FALSE ) ;
2014-02-16 09:09:55 -08:00
edi_mainview_save ( ) ;
}
static void
2014-03-31 14:24:56 -07:00
_tb_close_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
2014-02-16 09:09:55 -08:00
{
2014-03-31 14:24:56 -07:00
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( obj ) , EINA_FALSE ) ;
2014-02-16 09:09:55 -08:00
edi_mainview_close ( ) ;
}
2016-02-21 15:46:44 -08:00
static void
_tb_undo_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
{
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( obj ) , EINA_FALSE ) ;
edi_mainview_undo ( ) ;
}
2017-04-07 15:39:44 -07:00
static void
_tb_redo_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
{
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( obj ) , EINA_FALSE ) ;
edi_mainview_redo ( ) ;
}
2014-02-16 09:09:55 -08:00
static void
2014-03-31 14:24:56 -07:00
_tb_cut_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
2014-02-16 09:09:55 -08:00
{
2014-03-31 14:24:56 -07:00
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( obj ) , EINA_FALSE ) ;
2014-02-16 09:09:55 -08:00
edi_mainview_cut ( ) ;
}
static void
2014-03-31 14:24:56 -07:00
_tb_copy_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
2014-02-16 09:09:55 -08:00
{
2014-03-31 14:24:56 -07:00
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( obj ) , EINA_FALSE ) ;
2014-02-16 09:09:55 -08:00
edi_mainview_copy ( ) ;
}
static void
_tb_paste_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
{
2014-03-31 14:24:56 -07:00
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( obj ) , EINA_FALSE ) ;
2014-02-16 09:09:55 -08:00
edi_mainview_paste ( ) ;
2014-02-12 15:02:09 -08:00
}
2014-04-30 15:06:16 -07:00
static void
_tb_search_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
{
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( obj ) , EINA_FALSE ) ;
edi_mainview_search ( ) ;
}
2015-05-19 14:32:55 -07:00
static void
_tb_goto_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
{
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( obj ) , EINA_FALSE ) ;
2015-07-16 14:36:15 -07:00
edi_mainview_goto_popup_show ( ) ;
2015-05-19 14:32:55 -07:00
}
2014-11-09 06:08:52 -08:00
static Eina_Bool
2016-12-26 10:33:16 -08:00
_edi_build_prep ( Evas_Object * button )
2014-04-27 08:57:47 -07:00
{
2014-11-09 06:08:52 -08:00
elm_toolbar_item_selected_set ( elm_toolbar_selected_item_get ( button ) , EINA_FALSE ) ;
2014-04-27 08:57:47 -07:00
edi_consolepanel_clear ( ) ;
2016-12-26 10:33:16 -08:00
edi_consolepanel_show ( ) ;
2014-04-27 08:57:47 -07:00
2014-04-27 09:36:20 -07:00
if ( ! edi_builder_can_build ( ) )
{
2017-09-11 13:06:22 -07:00
edi_consolepanel_append_error_line ( _ ( " Cowardly refusing to build unknown project type. " ) ) ;
2014-11-09 06:08:52 -08:00
return EINA_FALSE ;
2014-04-27 09:36:20 -07:00
}
2014-11-09 06:08:52 -08:00
return EINA_TRUE ;
}
2017-07-04 06:10:55 -07:00
static void
_edi_launcher_run ( Edi_Project_Config_Launch * launch )
{
if ( ! edi_builder_can_run ( _edi_project_config - > launch . path ) )
{
edi_launcher_config_missing ( ) ;
return ;
}
edi_builder_run ( launch - > path , launch - > args ) ;
}
2018-11-25 09:05:16 -08:00
static void
_edi_launcher_terminate ( void )
{
pid_t pid = edi_exe_project_pid_get ( ) ;
if ( pid = = - 1 ) return ;
kill ( pid , SIGKILL ) ;
}
2017-09-20 08:47:30 -07:00
static void
_edi_build_menu_items_disabled_set ( Eina_Bool state )
{
2017-09-20 16:54:01 -07:00
elm_object_disabled_set ( _edi_toolbar_build , state ) ;
elm_object_disabled_set ( _edi_toolbar_test , state ) ;
2017-09-21 01:11:18 -07:00
elm_object_item_disabled_set ( _edi_menu_build , state ) ;
elm_object_item_disabled_set ( _edi_menu_test , state ) ;
elm_object_item_disabled_set ( _edi_menu_clean , state ) ;
2017-09-20 08:47:30 -07:00
}
2017-09-04 12:52:34 -07:00
static void
2017-09-07 16:16:10 -07:00
_edi_build_display_status_cb ( int status , void * data )
2017-09-04 12:52:34 -07:00
{
2017-09-07 16:16:10 -07:00
Eina_Strbuf * title , * message ;
const char * name = data ;
2017-09-04 12:52:34 -07:00
2017-09-07 16:16:10 -07:00
title = eina_strbuf_new ( ) ;
2017-09-04 12:52:34 -07:00
message = eina_strbuf_new ( ) ;
if ( status ! = 0 )
2017-09-11 13:06:22 -07:00
eina_strbuf_append_printf ( message , _ ( " %s of project <b>%s</b> in %s failed with status code %d. \n " ) , name , edi_project_name_get ( ) , edi_project_get ( ) , status ) ;
2017-09-04 12:52:34 -07:00
else
2017-09-11 13:06:22 -07:00
eina_strbuf_append_printf ( message , _ ( " %s of project <b>%s</b> in %s was successful. \n " ) , name , edi_project_name_get ( ) , edi_project_get ( ) ) ;
2017-09-04 12:52:34 -07:00
2017-09-19 12:34:15 -07:00
eina_strbuf_append_printf ( title , _ ( " %s %s " ) , name , status ? _ ( " Failed " ) : _ ( " Passed " ) ) ;
2017-09-04 12:52:34 -07:00
2017-09-07 16:16:10 -07:00
edi_screens_desktop_notify ( eina_strbuf_string_get ( title ) , eina_strbuf_string_get ( message ) ) ;
2017-09-20 08:47:30 -07:00
_edi_build_menu_items_disabled_set ( EINA_FALSE ) ;
2017-09-07 16:16:10 -07:00
eina_strbuf_free ( title ) ;
2017-09-04 12:52:34 -07:00
eina_strbuf_free ( message ) ;
}
2017-11-08 13:26:42 -08:00
static void
_edi_debug_project ( void )
{
edi_debugpanel_start ( _edi_project_config_debug_command_get ( ) ) ;
}
2017-09-05 07:58:00 -07:00
static void
_edi_build_project ( void )
{
2017-10-28 13:47:59 -07:00
if ( ! edi_build_provider_for_project_get ( ) )
return ;
2017-09-11 13:06:22 -07:00
if ( edi_exe_notify_handle ( " edi_build " , _edi_build_display_status_cb , _ ( " Build " ) ) )
2017-09-05 08:13:05 -07:00
{
2017-09-20 08:47:30 -07:00
_edi_build_menu_items_disabled_set ( EINA_TRUE ) ;
2017-09-05 08:13:05 -07:00
edi_consolepanel_show ( ) ;
edi_builder_build ( ) ;
}
2017-09-05 07:58:00 -07:00
}
2017-09-06 05:08:02 -07:00
static void
_edi_build_clean_project ( void )
{
2017-10-28 13:47:59 -07:00
if ( ! edi_build_provider_for_project_get ( ) )
return ;
2017-09-20 08:47:30 -07:00
if ( edi_exe_notify_handle ( " edi_clean " , _edi_build_display_status_cb , _ ( " Clean " ) ) )
2017-09-06 05:08:02 -07:00
{
2017-09-20 08:47:30 -07:00
_edi_build_menu_items_disabled_set ( EINA_TRUE ) ;
2017-09-06 05:08:02 -07:00
edi_consolepanel_show ( ) ;
edi_builder_clean ( ) ;
}
}
static void
_edi_build_test_project ( void )
{
2017-10-28 13:47:59 -07:00
if ( ! edi_build_provider_for_project_get ( ) )
return ;
2017-09-20 08:47:30 -07:00
if ( edi_exe_notify_handle ( " edi_test " , _edi_build_display_status_cb , _ ( " Test " ) ) )
2017-09-06 05:08:02 -07:00
{
2017-09-20 08:47:30 -07:00
_edi_build_menu_items_disabled_set ( EINA_TRUE ) ;
2017-09-06 05:08:02 -07:00
edi_consolepanel_show ( ) ;
edi_builder_test ( ) ;
}
}
2014-11-09 06:08:52 -08:00
static void
_tb_build_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
{
2016-12-26 10:33:16 -08:00
if ( _edi_build_prep ( obj ) )
2017-09-04 12:52:34 -07:00
_edi_build_project ( ) ;
2014-11-09 06:08:52 -08:00
}
static void
_tb_test_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
{
2016-12-26 10:33:16 -08:00
if ( _edi_build_prep ( obj ) )
2017-09-06 05:08:02 -07:00
_edi_build_test_project ( ) ;
2014-11-09 06:08:52 -08:00
}
2015-05-31 04:13:31 -07:00
2014-11-09 06:08:52 -08:00
static void
_tb_run_cb ( void * data EINA_UNUSED , Evas_Object * obj , void * event_info EINA_UNUSED )
{
2016-12-26 10:33:16 -08:00
if ( _edi_build_prep ( obj ) )
2015-05-31 04:13:31 -07:00
_edi_launcher_run ( & _edi_project_config - > launch ) ;
2014-11-09 06:08:52 -08:00
}
2015-05-31 04:13:31 -07:00
2014-11-09 06:08:52 -08:00
static void
2017-04-28 14:01:04 -07:00
_tb_debug_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED , void * event_info EINA_UNUSED )
2014-11-09 06:08:52 -08:00
{
2017-04-28 14:01:04 -07:00
edi_debugpanel_show ( ) ;
2017-11-08 13:26:42 -08:00
_edi_debug_project ( ) ;
2014-04-27 08:57:47 -07:00
}
2018-11-25 09:05:16 -08:00
static void
_tb_terminate_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED , void * event_info EINA_UNUSED )
{
_edi_launcher_terminate ( ) ;
}
2015-02-07 16:24:21 -08:00
static void
_tb_about_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED , void * event_info EINA_UNUSED )
{
2015-02-09 06:38:32 -08:00
edi_about_show ( _edi_main_win ) ;
2015-02-07 16:24:21 -08:00
}
2015-03-08 14:07:02 -07:00
static void
_tb_settings_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED , void * event_info EINA_UNUSED )
{
2018-12-17 06:15:41 -08:00
edi_settings_show ( _edi_main_win , EDI_SETTINGS_TAB_DISPLAY ) ;
2015-03-08 14:07:02 -07:00
}
2016-08-26 07:13:54 -07:00
static void
_edi_menu_project_new_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
char path [ PATH_MAX ] ;
eina_file_path_join ( path , sizeof ( path ) , elm_app_bin_dir_get ( ) , " edi -c " ) ;
ecore_exe_run ( path , NULL ) ;
}
2015-05-18 16:01:56 -07:00
static void
_edi_menu_new_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
2015-05-19 14:32:55 -07:00
void * event_info EINA_UNUSED )
2015-05-18 16:01:56 -07:00
{
2017-03-27 14:03:11 -07:00
const char * path , * selected ;
selected = edi_filepanel_selected_path_get ( _edi_filepanel ) ;
if ( selected & & ecore_file_is_dir ( selected ) )
path = selected ;
else
path = edi_project_get ( ) ;
2017-05-30 00:30:24 -07:00
edi_file_screens_create_file ( _edi_main_win , path ) ;
2017-03-27 14:03:11 -07:00
}
static void
_edi_menu_new_dir_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
const char * path , * selected ;
selected = edi_filepanel_selected_path_get ( _edi_filepanel ) ;
if ( selected & & ecore_file_is_dir ( selected ) )
path = selected ;
else
path = edi_project_get ( ) ;
2017-05-30 00:30:24 -07:00
edi_file_screens_create_dir ( _edi_main_win , path ) ;
2015-05-18 16:01:56 -07:00
}
static void
_edi_menu_save_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
2015-05-19 14:32:55 -07:00
void * event_info EINA_UNUSED )
2015-05-18 16:01:56 -07:00
{
edi_mainview_save ( ) ;
}
2015-05-19 14:32:55 -07:00
static void
_edi_menu_close_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_mainview_close ( ) ;
}
2016-02-15 16:15:52 -08:00
static void
_edi_menu_closeall_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
2017-07-23 13:54:47 -07:00
edi_mainview_close_all ( ) ;
2016-02-15 16:15:52 -08:00
}
2015-05-18 16:01:56 -07:00
static void
_edi_menu_settings_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
2015-05-19 14:32:55 -07:00
void * event_info EINA_UNUSED )
2015-05-18 16:01:56 -07:00
{
2018-12-17 06:15:41 -08:00
edi_settings_show ( _edi_main_win , EDI_SETTINGS_TAB_DISPLAY ) ;
2015-05-18 16:01:56 -07:00
}
static void
_edi_menu_quit_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
2015-05-19 14:32:55 -07:00
void * event_info EINA_UNUSED )
2015-05-18 16:01:56 -07:00
{
2017-04-28 14:01:04 -07:00
edi_close ( ) ;
2015-05-18 16:01:56 -07:00
}
2016-02-21 15:46:44 -08:00
static void
_edi_menu_undo_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_mainview_undo ( ) ;
}
2017-04-07 15:39:44 -07:00
static void
_edi_menu_redo_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_mainview_redo ( ) ;
}
2015-05-19 14:32:55 -07:00
static void
_edi_menu_cut_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_mainview_cut ( ) ;
}
static void
_edi_menu_copy_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_mainview_copy ( ) ;
}
static void
_edi_menu_paste_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_mainview_paste ( ) ;
}
static void
_edi_menu_find_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_mainview_search ( ) ;
}
2017-03-30 15:03:19 -07:00
static void
_edi_menu_find_project_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_mainview_project_search_popup_show ( ) ;
}
2017-09-27 17:23:18 -07:00
static void
_edi_menu_find_replace_project_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_mainview_project_replace_popup_show ( ) ;
}
2016-02-11 06:13:12 -08:00
static void
_edi_menu_findfile_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_filepanel_search ( ) ;
}
2017-04-05 11:15:47 -07:00
static void
2017-07-23 13:54:47 -07:00
_edi_menu_goto_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
2017-04-05 11:15:47 -07:00
{
2017-07-23 13:54:47 -07:00
edi_mainview_goto_popup_show ( ) ;
2017-04-05 11:15:47 -07:00
}
2015-05-19 14:32:55 -07:00
static void
2017-07-23 13:54:47 -07:00
_edi_menu_view_open_window_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
2015-05-19 14:32:55 -07:00
{
2017-07-23 13:54:47 -07:00
edi_mainview_new_window ( ) ;
}
2017-10-10 15:29:17 -07:00
static void
_edi_menu_view_split_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_mainview_split_current ( ) ;
}
2017-07-23 13:54:47 -07:00
static void
2017-09-02 02:27:10 -07:00
_edi_menu_view_new_panel_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
2017-07-23 13:54:47 -07:00
void * event_info EINA_UNUSED )
{
edi_mainview_panel_append ( ) ;
}
static void
_edi_menu_view_tasks_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_taskspanel_show ( ) ;
edi_taskspanel_find ( ) ;
2015-05-19 14:32:55 -07:00
}
static void
_edi_menu_build_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
2017-09-04 12:52:34 -07:00
_edi_build_project ( ) ;
2015-05-19 14:32:55 -07:00
}
static void
_edi_menu_test_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
2017-09-06 05:08:02 -07:00
_edi_build_test_project ( ) ;
2015-05-19 14:32:55 -07:00
}
2015-05-31 04:13:31 -07:00
static void
_edi_menu_run_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
_edi_launcher_run ( & _edi_project_config - > launch ) ;
}
2018-11-25 09:05:16 -08:00
static void
_edi_menu_terminate_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
_edi_launcher_terminate ( ) ;
}
2015-05-19 14:32:55 -07:00
static void
_edi_menu_clean_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
2017-09-06 05:08:02 -07:00
_edi_build_clean_project ( ) ;
2015-05-19 14:32:55 -07:00
}
2017-11-08 13:26:42 -08:00
static void
_edi_menu_memcheck_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_debugpanel_show ( ) ;
edi_debugpanel_stop ( ) ;
edi_debugpanel_start ( " memcheck " ) ;
}
2017-04-28 14:01:04 -07:00
static void
_edi_menu_debug_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_debugpanel_show ( ) ;
2017-11-08 13:26:42 -08:00
_edi_debug_project ( ) ;
2017-04-28 14:01:04 -07:00
}
2017-06-06 17:45:44 -07:00
static void
_edi_menu_scm_init_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
if ( ! _edi_project_credentials_check ( ) )
{
_edi_project_credentials_missing ( ) ;
return ;
}
if ( ! ecore_file_app_installed ( " git " ) )
{
2017-09-29 13:37:21 -07:00
edi_screens_scm_binary_missing ( _edi_main_win , " git " ) ;
2017-06-06 17:45:44 -07:00
return ;
}
edi_consolepanel_clear ( ) ;
edi_consolepanel_show ( ) ;
edi_scm_git_new ( ) ;
2017-09-16 12:41:46 -07:00
edi_scm_init ( ) ;
2017-09-17 08:34:35 -07:00
edi_filepanel_scm_status_update ( ) ;
edi_filepanel_status_refresh ( ) ;
2017-06-06 17:45:44 -07:00
_edi_icon_update ( ) ;
}
2017-09-29 13:37:21 -07:00
static void
_edi_scm_program_exited_cb ( int status EINA_UNUSED , void * data EINA_UNUSED )
{
edi_filepanel_status_refresh ( ) ;
}
2017-06-06 17:45:44 -07:00
static void
_edi_menu_scm_commit_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
2017-09-29 13:37:21 -07:00
char * workdir = getcwd ( NULL , PATH_MAX ) ;
2017-06-06 17:45:44 -07:00
if ( ! _edi_project_credentials_check ( ) )
{
_edi_project_credentials_missing ( ) ;
return ;
}
2017-09-29 13:37:21 -07:00
chdir ( edi_project_get ( ) ) ;
/* when program terminates update the filepanel */
if ( edi_exe_notify_handle ( " edi_scm_status " , _edi_scm_program_exited_cb , NULL ) )
2017-12-30 12:08:44 -08:00
edi_exe_notify ( " edi_scm_status " , " edi_scm --commit " ) ;
2017-09-29 13:37:21 -07:00
chdir ( workdir ) ;
free ( workdir ) ;
2017-06-06 17:45:44 -07:00
}
static void
2017-07-16 11:59:33 -07:00
_edi_scm_stash_do_cb ( void * data EINA_UNUSED )
2017-06-06 17:45:44 -07:00
{
edi_scm_stash ( ) ;
2017-09-19 06:38:23 -07:00
edi_filepanel_status_refresh ( ) ;
2017-06-06 17:45:44 -07:00
}
2017-07-16 11:59:33 -07:00
static void
_edi_menu_scm_stash_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
2017-09-11 13:06:22 -07:00
edi_screens_message_confirm ( _edi_main_win , _ ( " Are you sure you wish to stash these changes? " ) ,
2017-07-16 11:59:33 -07:00
_edi_scm_stash_do_cb , NULL ) ;
}
2017-06-06 17:45:44 -07:00
static void
_edi_menu_scm_status_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_consolepanel_clear ( ) ;
edi_consolepanel_show ( ) ;
edi_scm_status ( ) ;
}
static void
_edi_menu_scm_pull_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_consolepanel_clear ( ) ;
edi_consolepanel_show ( ) ;
edi_scm_pull ( ) ;
}
static void
_edi_menu_scm_push_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
if ( ! _edi_project_credentials_check ( ) )
{
_edi_project_credentials_missing ( ) ;
return ;
}
edi_consolepanel_clear ( ) ;
edi_consolepanel_show ( ) ;
edi_scm_push ( ) ;
}
2015-05-19 14:32:55 -07:00
static void
_edi_menu_website_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_open_url ( " http://edi-ide.com " ) ;
}
static void
_edi_menu_about_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED ,
void * event_info EINA_UNUSED )
{
edi_about_show ( _edi_main_win ) ;
}
2015-05-18 16:01:56 -07:00
static void
2017-06-16 04:24:03 -07:00
_edi_menu_setup ( Evas_Object * win )
2015-05-18 16:01:56 -07:00
{
2017-07-05 13:04:38 -07:00
Evas_Object * menu ;
2015-05-18 16:01:56 -07:00
Elm_Object_Item * menu_it ;
2017-06-18 11:18:21 -07:00
static Eina_Bool setup = EINA_FALSE ;
if ( setup ) return ;
setup = EINA_TRUE ;
2015-05-18 16:01:56 -07:00
2017-06-16 04:24:03 -07:00
menu = elm_win_main_menu_get ( win ) ;
2017-09-11 13:06:22 -07:00
menu_it = elm_menu_item_add ( menu , NULL , NULL , _ ( " File " ) , NULL , NULL ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " folder-new " ) , MENU_ELLIPSIS ( _ ( " New Project " ) ) , _edi_menu_project_new_cb , NULL ) ;
2016-08-26 07:13:54 -07:00
elm_menu_item_separator_add ( menu , menu_it ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " document-new " ) , MENU_ELLIPSIS ( _ ( " New " ) ) , _edi_menu_new_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " folder-new " ) , MENU_ELLIPSIS ( _ ( " New Directory " ) ) , _edi_menu_new_dir_cb , NULL ) ;
_edi_menu_save = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " document-save " ) , _ ( " Save " ) , _edi_menu_save_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " window-close " ) , _ ( " Close " ) , _edi_menu_close_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " window-close " ) , _ ( " Close all " ) , _edi_menu_closeall_cb , NULL ) ;
2015-05-19 14:32:55 -07:00
elm_menu_item_separator_add ( menu , menu_it ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " preferences-desktop " ) , _ ( " Settings " ) , _edi_menu_settings_cb , NULL ) ;
2015-05-18 16:01:56 -07:00
elm_menu_item_separator_add ( menu , menu_it ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " application-exit " ) , _ ( " Quit " ) , _edi_menu_quit_cb , NULL ) ;
2015-05-19 14:32:55 -07:00
2017-09-11 13:06:22 -07:00
menu_it = elm_menu_item_add ( menu , NULL , NULL , _ ( " Edit " ) , NULL , NULL ) ;
2019-12-26 10:53:38 -08:00
_edi_menu_undo = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-undo " ) , _ ( " Undo " ) , _edi_menu_undo_cb , NULL ) ;
_edi_menu_redo = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-redo " ) , _ ( " Redo " ) , _edi_menu_redo_cb , NULL ) ;
2016-02-21 15:46:44 -08:00
elm_menu_item_separator_add ( menu , menu_it ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-cut " ) , _ ( " Cut " ) , _edi_menu_cut_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-copy " ) , _ ( " Copy " ) , _edi_menu_copy_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-paste " ) , _ ( " Paste " ) , _edi_menu_paste_cb , NULL ) ;
2015-05-19 14:32:55 -07:00
elm_menu_item_separator_add ( menu , menu_it ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-find-replace " ) , _ ( " Find & Replace " ) , _edi_menu_find_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-find " ) , _ ( " Find file " ) , _edi_menu_findfile_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " go-jump " ) , MENU_ELLIPSIS ( _ ( " Goto Line " ) ) , _edi_menu_goto_cb , NULL ) ;
2017-03-30 15:03:19 -07:00
elm_menu_item_separator_add ( menu , menu_it ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-find " ) , MENU_ELLIPSIS ( _ ( " Find in project " ) ) , _edi_menu_find_project_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-find-replace " ) , MENU_ELLIPSIS ( _ ( " Replace in project " ) ) , _edi_menu_find_replace_project_cb , NULL ) ;
2017-07-23 13:54:47 -07:00
2017-09-11 13:06:22 -07:00
menu_it = elm_menu_item_add ( menu , NULL , NULL , _ ( " View " ) , NULL , NULL ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " window-new " ) , _ ( " New Window " ) , _edi_menu_view_open_window_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " object-flip-horizontal " ) , _ ( " New Panel " ) , _edi_menu_view_new_panel_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " object-flip-vertical " ) , _ ( " Split View " ) , _edi_menu_view_split_cb , NULL ) ;
2017-07-23 13:54:47 -07:00
elm_menu_item_separator_add ( menu , menu_it ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-find " ) , _ ( " Open Tasks " ) , _edi_menu_view_tasks_cb , NULL ) ;
2017-09-11 13:06:22 -07:00
menu_it = elm_menu_item_add ( menu , NULL , NULL , _ ( " Build " ) , NULL , NULL ) ;
2019-12-26 10:53:38 -08:00
_edi_menu_build = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " system-run " ) , _ ( " Build " ) , _edi_menu_build_cb , NULL ) ;
_edi_menu_test = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " media-record " ) , _ ( " Test " ) , _edi_menu_test_cb , NULL ) ;
_edi_menu_clean = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-clear " ) , _ ( " Clean " ) , _edi_menu_clean_cb , NULL ) ;
2017-11-19 14:14:56 -08:00
elm_menu_item_separator_add ( menu , menu_it ) ;
2019-12-26 10:53:38 -08:00
_edi_menu_run = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " media-playback-start " ) , _ ( " Run " ) , _edi_menu_run_cb , NULL ) ;
_edi_menu_terminate = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " media-playback-stop " ) , _ ( " Terminate " ) , _edi_menu_terminate_cb , NULL ) ;
2018-11-25 09:05:16 -08:00
elm_menu_item_separator_add ( menu , menu_it ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " utilities-terminal " ) , _ ( " Debugger " ) , _edi_menu_debug_cb , NULL ) ;
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " applications-electronics " ) , _ ( " Memcheck " ) , _edi_menu_memcheck_cb , NULL ) ;
2017-11-08 13:26:42 -08:00
2017-09-11 13:06:22 -07:00
menu_it = elm_menu_item_add ( menu , NULL , NULL , _ ( " Project " ) , NULL , NULL ) ;
2019-12-26 10:53:38 -08:00
_edi_menu_init = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " media-playback-start " ) , _ ( " Init " ) , _edi_menu_scm_init_cb , NULL ) ;
_edi_menu_commit = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " mail-send " ) , _ ( " Commit " ) , _edi_menu_scm_commit_cb , NULL ) ;
_edi_menu_stash = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " edit-undo " ) , _ ( " Stash " ) , _edi_menu_scm_stash_cb , NULL ) ;
_edi_menu_status = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " dialog-error " ) , _ ( " Status " ) , _edi_menu_scm_status_cb , NULL ) ;
_edi_menu_push = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " go-up " ) , _ ( " Push " ) , _edi_menu_scm_push_cb , NULL ) ;
_edi_menu_pull = elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " go-down " ) , _ ( " Pull " ) , _edi_menu_scm_pull_cb , NULL ) ;
2017-09-11 13:06:22 -07:00
menu_it = elm_menu_item_add ( menu , NULL , NULL , _ ( " Help " ) , NULL , NULL ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " go-home " ) , _ ( " Visit Website " ) , _edi_menu_website_cb , NULL ) ;
2015-05-18 16:01:56 -07:00
elm_menu_item_separator_add ( menu , menu_it ) ;
2019-12-26 10:53:38 -08:00
elm_menu_item_add ( menu , menu_it , edi_theme_icon_path_get ( " help-about " ) , _ ( " About " ) , _edi_menu_about_cb , NULL ) ;
2015-05-18 16:01:56 -07:00
}
2017-04-07 15:39:44 -07:00
static Evas_Object *
2016-09-25 09:23:07 -07:00
_edi_toolbar_item_add ( Evas_Object * tb , const char * icon , const char * name , Evas_Smart_Cb func )
{
Evas_Object * content ;
Elm_Object_Item * tb_it ;
2019-12-26 06:24:42 -08:00
if ( ! _edi_project_config - > gui . internal_icons )
tb_it = elm_toolbar_item_append ( tb , icon , NULL , func , NULL ) ;
else
tb_it = elm_toolbar_item_append ( tb , edi_theme_icon_path_get ( icon ) , NULL , func , NULL ) ;
2016-09-25 09:23:07 -07:00
content = elm_toolbar_item_object_get ( tb_it ) ;
elm_object_tooltip_text_set ( content , name ) ;
2017-04-07 15:39:44 -07:00
return content ;
2016-09-25 09:23:07 -07:00
}
2019-12-22 06:42:06 -08:00
static void
2019-12-28 09:30:26 -08:00
edi_toolbar_setup ( void )
2014-02-12 15:02:09 -08:00
{
2019-12-28 09:30:26 -08:00
Evas_Object * win , * tb ;
2014-02-16 09:09:55 -08:00
Elm_Object_Item * tb_it ;
2019-12-28 09:30:26 -08:00
Eina_Bool is_horizontal = _edi_project_config - > gui . toolbar_horizontal ;
2019-12-23 16:51:06 -08:00
2019-12-28 09:30:26 -08:00
win = edi_main_win_get ( ) ;
2019-12-22 06:42:06 -08:00
2019-12-28 09:30:26 -08:00
_edi_toolbar = tb = elm_toolbar_add ( win ) ;
elm_toolbar_align_set ( tb , 0.0 ) ;
elm_toolbar_shrink_mode_set ( tb , ELM_TOOLBAR_SHRINK_SCROLL ) ;
2019-12-26 10:00:55 -08:00
elm_toolbar_select_mode_set ( tb , ELM_OBJECT_SELECT_MODE_NONE ) ;
2019-12-22 06:42:06 -08:00
elm_toolbar_horizontal_set ( tb , _edi_project_config - > gui . toolbar_horizontal ) ;
2019-12-22 11:34:59 -08:00
elm_toolbar_homogeneous_set ( tb , EINA_FALSE ) ;
2019-12-28 09:30:26 -08:00
elm_object_focus_allow_set ( tb , EINA_FALSE ) ;
2019-12-22 06:42:06 -08:00
elm_toolbar_icon_size_set ( tb , 48 * elm_config_scale_get ( ) ) ;
2019-12-20 18:37:54 -08:00
evas_object_size_hint_align_set ( tb , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
2019-12-28 09:30:26 -08:00
if ( is_horizontal )
evas_object_size_hint_weight_set ( tb , EVAS_HINT_EXPAND , 0.0 ) ;
else
evas_object_size_hint_weight_set ( tb , 0.0 , EVAS_HINT_EXPAND ) ;
2019-12-26 10:00:55 -08:00
evas_object_show ( tb ) ;
2014-02-12 15:02:09 -08:00
2017-09-11 13:06:22 -07:00
_edi_toolbar_item_add ( tb , " document-new " , _ ( " New File " ) , _tb_new_cb ) ;
_edi_toolbar_save = _edi_toolbar_item_add ( tb , " document-save " , _ ( " Save " ) , _tb_save_cb ) ;
2017-10-21 06:19:40 -07:00
_edi_toolbar_item_add ( tb , " window-close " , _ ( " Close " ) , _tb_close_cb ) ;
2014-02-12 15:02:09 -08:00
2019-12-26 10:00:55 -08:00
tb_it = elm_toolbar_item_append ( tb , " separator " , " " , NULL , NULL ) ;
elm_toolbar_item_separator_set ( tb_it , EINA_TRUE ) ;
2017-09-11 13:06:22 -07:00
_edi_toolbar_undo = _edi_toolbar_item_add ( tb , " edit-undo " , _ ( " Undo " ) , _tb_undo_cb ) ;
_edi_toolbar_redo = _edi_toolbar_item_add ( tb , " edit-redo " , _ ( " Redo " ) , _tb_redo_cb ) ;
2014-03-31 14:24:56 -07:00
2019-12-26 10:00:55 -08:00
tb_it = elm_toolbar_item_append ( tb , " separator " , " " , NULL , NULL ) ;
elm_toolbar_item_separator_set ( tb_it , EINA_TRUE ) ;
2017-09-11 13:06:22 -07:00
_edi_toolbar_item_add ( tb , " edit-cut " , _ ( " Cut " ) , _tb_cut_cb ) ;
_edi_toolbar_item_add ( tb , " edit-copy " , _ ( " Copy " ) , _tb_copy_cb ) ;
_edi_toolbar_item_add ( tb , " edit-paste " , _ ( " Paste " ) , _tb_paste_cb ) ;
2014-04-30 15:06:16 -07:00
2019-12-26 10:00:55 -08:00
tb_it = elm_toolbar_item_append ( tb , " separator " , " " , NULL , NULL ) ;
elm_toolbar_item_separator_set ( tb_it , EINA_TRUE ) ;
2017-11-19 14:07:53 -08:00
_edi_toolbar_item_add ( tb , " edit-find-replace " , MENU_ELLIPSIS ( _ ( " Find " ) ) , _tb_search_cb ) ;
2017-09-11 13:06:22 -07:00
_edi_toolbar_item_add ( tb , " go-jump " , _ ( " Goto Line " ) , _tb_goto_cb ) ;
2014-04-27 08:57:47 -07:00
2019-12-26 10:00:55 -08:00
tb_it = elm_toolbar_item_append ( tb , " separator " , " " , NULL , NULL ) ;
elm_toolbar_item_separator_set ( tb_it , EINA_TRUE ) ;
2017-09-20 16:54:01 -07:00
_edi_toolbar_build = _edi_toolbar_item_add ( tb , " system-run " , _ ( " Build " ) , _tb_build_cb ) ;
_edi_toolbar_test = _edi_toolbar_item_add ( tb , " media-record " , _ ( " Test " ) , _tb_test_cb ) ;
2019-12-15 04:39:46 -08:00
2018-11-25 09:05:16 -08:00
_edi_toolbar_run = _edi_toolbar_item_add ( tb , " media-playback-start " , _ ( " Run " ) , _tb_run_cb ) ;
_edi_toolbar_terminate = _edi_toolbar_item_add ( tb , " media-playback-stop " , _ ( " Terminate " ) , _tb_terminate_cb ) ;
2017-09-11 13:06:22 -07:00
_edi_toolbar_item_add ( tb , " utilities-terminal " , _ ( " Debug " ) , _tb_debug_cb ) ;
2015-02-07 16:24:21 -08:00
2016-09-25 09:23:07 -07:00
tb_it = elm_toolbar_item_append ( tb , " separator " , " " , NULL , NULL ) ;
elm_toolbar_item_separator_set ( tb_it , EINA_TRUE ) ;
2017-09-11 13:06:22 -07:00
_edi_toolbar_item_add ( tb , " preferences-desktop " , _ ( " Settings " ) , _tb_settings_cb ) ;
_edi_toolbar_item_add ( tb , " help-about " , _ ( " About " ) , _tb_about_cb ) ;
2015-02-07 16:24:21 -08:00
2019-12-28 09:30:26 -08:00
if ( is_horizontal )
{
elm_box_pack_start ( _edi_toolbar_hbx , tb ) ;
elm_box_pack_start ( _edi_main_box , _edi_toolbar_hbx ) ;
elm_box_horizontal_set ( _edi_main_box , EINA_FALSE ) ;
elm_box_recalculate ( _edi_toolbar_hbx ) ;
_edi_toolbar_main_box = _edi_toolbar_hbx ;
}
else
{
elm_box_horizontal_set ( _edi_main_box , EINA_TRUE ) ;
elm_box_pack_start ( _edi_toolbar_vbx , tb ) ;
elm_box_pack_start ( _edi_main_box , _edi_toolbar_vbx ) ;
_edi_toolbar_main_box = _edi_toolbar_vbx ;
}
2014-02-12 15:02:09 -08:00
}
2014-02-16 11:54:06 -08:00
static char *
2016-11-04 07:49:39 -07:00
_edi_win_title_get ( )
2014-02-16 11:54:06 -08:00
{
2016-11-04 07:49:39 -07:00
char * winname ;
const char * name , * type ;
2016-05-16 00:58:32 -07:00
Edi_Build_Provider * provider ;
int len ;
provider = edi_build_provider_for_project_get ( ) ;
if ( provider )
type = provider - > id ;
else
2017-12-30 10:52:41 -08:00
type = _ ( " unknown " ) ;
2014-02-16 11:54:06 -08:00
2016-11-04 07:49:39 -07:00
name = edi_project_name_get ( ) ;
len = 8 + 3 + strlen ( name ) + strlen ( type ) ;
2016-05-16 00:58:32 -07:00
winname = malloc ( len * sizeof ( char ) ) ;
2017-12-30 10:52:41 -08:00
snprintf ( winname , len , _ ( " Edi :: %s (%s) " ) , name , type ) ;
2014-02-16 11:54:06 -08:00
return winname ;
}
2014-06-29 15:54:29 -07:00
static void
_edi_exit ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED , void * event_info EINA_UNUSED )
{
edi_close ( ) ;
}
2018-08-19 06:17:07 -07:00
static void
_edi_focused_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED , void * event_info EINA_UNUSED )
{
Evas_Object * win = edi_settings_win_get ( ) ;
if ( win )
elm_win_raise ( win ) ;
}
2014-12-03 15:52:12 -08:00
static void
_edi_resize_cb ( void * data EINA_UNUSED , Evas * e EINA_UNUSED , Evas_Object * obj ,
void * event_info EINA_UNUSED )
{
int w , h ;
evas_object_geometry_get ( obj , NULL , NULL , & w , & h ) ;
w / = elm_config_scale_get ( ) ;
h / = elm_config_scale_get ( ) ;
2015-05-16 01:56:39 -07:00
_edi_project_config - > gui . width = w + 1 ;
_edi_project_config - > gui . height = h + 1 ;
_edi_project_config_save ( ) ;
2014-12-03 15:52:12 -08:00
}
2019-12-28 09:30:26 -08:00
static void
_edi_toolbar_visible_set ( Eina_Bool visible )
{
elm_box_unpack ( _edi_main_box , _edi_toolbar_main_box ) ;
if ( visible )
{
evas_object_show ( _edi_toolbar_main_box ) ;
evas_object_show ( _edi_toolbar ) ;
}
else
{
evas_object_hide ( _edi_toolbar_main_box ) ;
evas_object_hide ( _edi_toolbar ) ;
}
if ( visible )
{
elm_box_pack_start ( _edi_main_box , _edi_toolbar_main_box ) ;
}
}
2015-05-18 15:17:24 -07:00
static Eina_Bool
_edi_config_changed ( void * data EINA_UNUSED , int type EINA_UNUSED , void * event EINA_UNUSED )
{
2018-05-15 08:13:55 -07:00
edi_theme_window_alpha_set ( ) ;
2017-12-06 11:45:49 -08:00
2019-12-28 09:30:26 -08:00
_edi_toolbar_visible_set ( ! _edi_project_config - > gui . toolbar_hidden ) ;
2019-12-22 06:42:06 -08:00
2015-05-18 15:17:24 -07:00
return ECORE_CALLBACK_RENEW ;
}
2017-04-07 15:39:44 -07:00
static Eina_Bool
_edi_tab_changed ( void * data EINA_UNUSED , int type EINA_UNUSED , void * event EINA_UNUSED )
{
_edi_icon_update ( ) ;
2019-12-22 06:42:06 -08:00
2017-04-07 15:39:44 -07:00
return ECORE_CALLBACK_RENEW ;
}
static Eina_Bool
_edi_file_changed ( void * data EINA_UNUSED , int type EINA_UNUSED , void * event EINA_UNUSED )
{
_edi_icon_update ( ) ;
return ECORE_CALLBACK_RENEW ;
}
2017-04-22 14:23:32 -07:00
static Eina_Bool
_edi_file_saved ( void * data EINA_UNUSED , int type EINA_UNUSED , void * event EINA_UNUSED )
{
elm_object_item_disabled_set ( _edi_menu_save , EINA_TRUE ) ;
elm_object_disabled_set ( _edi_toolbar_save , EINA_TRUE ) ;
return ECORE_CALLBACK_RENEW ;
}
2015-05-18 08:32:46 -07:00
void
_edi_open_tabs ( )
{
2017-07-24 15:28:48 -07:00
Edi_Project_Config_Panel * panel ;
2015-05-18 08:32:46 -07:00
Edi_Project_Config_Tab * tab ;
2017-06-08 18:31:45 -07:00
Edi_Path_Options * options ;
2017-07-24 15:28:48 -07:00
Eina_List * tabs , * panels , * list , * sublist ;
Edi_Mainview_Panel * panel_obj ;
2017-01-02 13:19:55 -08:00
char * path ;
2017-12-01 05:07:00 -08:00
int i ;
2017-07-24 15:28:48 -07:00
unsigned int tab_id = 0 , panel_id = 0 ;
2015-05-18 08:32:46 -07:00
2017-07-24 15:28:48 -07:00
panels = _edi_project_config - > panels ;
_edi_project_config - > panels = NULL ;
EINA_LIST_FOREACH ( panels , list , panel )
{
if ( panel_id ! = 0 )
/* Make sure we have enough panels */
edi_mainview_panel_append ( ) ;
panel_obj = edi_mainview_panel_by_index ( panel_id ) ;
2017-12-01 05:07:00 -08:00
edi_mainview_panel_focus ( panel_obj ) ;
2017-07-24 15:28:48 -07:00
tabs = panel - > tabs ;
panel - > tabs = NULL ;
tab_id = 0 ;
EINA_LIST_FOREACH ( tabs , sublist , tab )
{
if ( ! strncmp ( tab - > path , edi_project_get ( ) , strlen ( edi_project_get ( ) ) ) )
path = strdup ( tab - > path ) ;
else
path = edi_path_append ( edi_project_get ( ) , tab - > path ) ;
options = edi_path_options_create ( path ) ;
options - > type = eina_stringshare_add ( tab - > type ) ;
options - > background = tab_id ! = panel - > current_tab ;
tab_id + + ;
2017-12-01 05:07:00 -08:00
edi_mainview_panel_open ( panel_obj , options ) ;
for ( i = 0 ; i < tab - > split_views ; i + + )
{
edi_mainview_panel_tab_select ( panel_obj , tab_id ) ;
edi_mainview_split_current ( ) ;
}
2017-07-24 15:28:48 -07:00
free ( path ) ;
}
edi_mainview_panel_tab_select ( panel_obj , panel - > current_tab ) ;
panel_id + + ;
EINA_LIST_FREE ( tabs , tab )
{
free ( tab ) ;
}
}
tabs = _edi_project_config - > windows ;
_edi_project_config - > windows = NULL ;
2015-06-09 14:31:33 -07:00
EINA_LIST_FOREACH ( tabs , list , tab )
2015-05-18 08:32:46 -07:00
{
2017-01-02 13:19:55 -08:00
if ( ! strncmp ( tab - > path , edi_project_get ( ) , strlen ( edi_project_get ( ) ) ) )
path = strdup ( tab - > path ) ;
else
path = edi_path_append ( edi_project_get ( ) , tab - > path ) ;
2017-06-08 18:31:45 -07:00
options = edi_path_options_create ( path ) ;
options - > type = eina_stringshare_add ( tab - > type ) ;
2017-07-23 13:54:47 -07:00
2017-07-24 15:28:48 -07:00
edi_mainview_open_window ( options ) ;
2017-01-02 13:19:55 -08:00
free ( path ) ;
2015-05-18 08:32:46 -07:00
}
2015-06-09 14:31:33 -07:00
EINA_LIST_FREE ( tabs , tab )
{
free ( tab ) ;
}
2015-05-18 08:32:46 -07:00
}
2017-04-28 14:01:04 -07:00
static void
_win_delete_cb ( void * data EINA_UNUSED , Evas_Object * obj EINA_UNUSED , void * event EINA_UNUSED )
{
edi_close ( ) ;
}
2017-12-05 14:03:46 -08:00
Evas_Object * edi_main_win_get ( void )
{
return _edi_main_win ;
}
2016-07-03 13:06:22 -07:00
Eina_Bool
2014-11-12 15:43:18 -08:00
edi_open ( const char * inputpath )
2014-02-12 12:56:20 -08:00
{
2019-12-28 09:30:26 -08:00
Evas_Object * table , * win , * bg , * vbx , * content ;
Evas_Object * vbx_tb , * hbx_tb ;
2017-07-04 02:35:39 -07:00
char * winname ;
2014-11-12 15:43:18 -08:00
char * path ;
2014-02-16 11:54:06 -08:00
2014-11-12 15:43:18 -08:00
if ( ! edi_project_set ( inputpath ) )
2014-10-22 14:41:23 -07:00
{
2017-09-11 13:06:22 -07:00
fprintf ( stderr , _ ( " Project path must be a directory \n " ) ) ;
2016-07-03 13:06:22 -07:00
return EINA_FALSE ;
2014-10-22 14:41:23 -07:00
}
2014-11-12 15:43:18 -08:00
path = realpath ( inputpath , NULL ) ;
2015-05-18 07:46:39 -07:00
_edi_project_config_load ( ) ;
2014-02-12 12:56:20 -08:00
2014-02-16 11:54:06 -08:00
elm_need_ethumb ( ) ;
elm_need_efreet ( ) ;
2016-11-04 07:49:39 -07:00
winname = _edi_win_title_get ( ) ;
2014-02-16 11:54:06 -08:00
win = elm_win_util_standard_add ( " main " , winname ) ;
2017-07-04 02:35:39 -07:00
free ( winname ) ;
2016-07-03 13:06:22 -07:00
if ( ! win ) return EINA_FALSE ;
2014-02-12 12:56:20 -08:00
2014-03-31 14:24:56 -07:00
_edi_main_win = win ;
2014-02-12 12:56:20 -08:00
elm_win_focus_highlight_enabled_set ( win , EINA_TRUE ) ;
2014-02-16 11:54:06 -08:00
evas_object_smart_callback_add ( win , " delete,request " , _edi_exit , NULL ) ;
2014-12-03 15:52:12 -08:00
evas_object_event_callback_add ( win , EVAS_CALLBACK_RESIZE , _edi_resize_cb , NULL ) ;
2018-08-19 06:17:07 -07:00
evas_object_smart_callback_add ( win , " focused " , _edi_focused_cb , NULL ) ;
2014-02-12 12:56:20 -08:00
2018-08-01 15:23:44 -07:00
table = elm_table_add ( win ) ;
evas_object_size_hint_weight_set ( table , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( table , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
evas_object_show ( table ) ;
2019-12-28 09:30:26 -08:00
vbx = elm_box_add ( win ) ;
_edi_main_box = vbx ;
elm_box_horizontal_set ( vbx , EINA_FALSE ) ;
evas_object_size_hint_weight_set ( vbx , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( vbx , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
evas_object_show ( vbx ) ;
2014-02-12 12:56:20 -08:00
2018-08-01 15:23:44 -07:00
bg = elm_bg_add ( win ) ;
evas_object_size_hint_weight_set ( bg , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( bg , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
evas_object_show ( bg ) ;
elm_win_resize_object_add ( win , table ) ;
elm_table_pack ( table , bg , 0 , 0 , 1 , 1 ) ;
2019-12-28 09:30:26 -08:00
elm_table_pack ( table , vbx , 0 , 0 , 1 , 1 ) ;
_edi_toolbar_vbx = vbx_tb = elm_box_add ( win ) ;
elm_box_horizontal_set ( vbx_tb , EINA_FALSE ) ;
evas_object_size_hint_weight_set ( vbx_tb , 0.0 , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( vbx_tb , 0.0 , EVAS_HINT_FILL ) ;
evas_object_show ( vbx_tb ) ;
_edi_toolbar_hbx = hbx_tb = elm_box_add ( win ) ;
elm_box_horizontal_set ( hbx_tb , EINA_TRUE ) ;
evas_object_size_hint_weight_set ( hbx_tb , EVAS_HINT_EXPAND , 0.0 ) ;
evas_object_size_hint_align_set ( hbx_tb , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
evas_object_show ( hbx_tb ) ;
2018-08-01 15:23:44 -07:00
2019-12-22 06:42:06 -08:00
edi_theme_window_alpha_set ( ) ;
2018-08-01 15:23:44 -07:00
evas_object_data_set ( win , " background " , bg ) ;
2019-12-28 09:30:26 -08:00
evas_object_data_set ( win , " mainbox " , vbx ) ;
2018-08-01 15:23:44 -07:00
2019-12-28 09:30:26 -08:00
edi_toolbar_setup ( ) ;
2016-09-25 09:23:07 -07:00
2017-07-03 23:00:16 -07:00
_edi_menu_setup ( win ) ;
2019-12-28 09:30:26 -08:00
content = edi_content_setup ( vbx , path ) ;
2014-02-12 15:20:29 -08:00
evas_object_size_hint_weight_set ( content , EVAS_HINT_EXPAND , EVAS_HINT_EXPAND ) ;
evas_object_size_hint_align_set ( content , EVAS_HINT_FILL , EVAS_HINT_FILL ) ;
2019-12-28 09:30:26 -08:00
elm_box_pack_end ( vbx , content ) ;
2014-02-12 12:56:20 -08:00
2014-12-01 14:54:17 -08:00
_edi_config_project_add ( path ) ;
2015-05-18 08:32:46 -07:00
_edi_open_tabs ( ) ;
2017-06-06 17:45:44 -07:00
edi_scm_init ( ) ;
2017-04-07 15:39:44 -07:00
_edi_icon_update ( ) ;
2017-04-28 14:01:04 -07:00
evas_object_smart_callback_add ( win , " delete,request " , _win_delete_cb , NULL ) ;
2015-05-18 15:17:24 -07:00
ecore_event_handler_add ( EDI_EVENT_CONFIG_CHANGED , _edi_config_changed , NULL ) ;
2017-04-07 15:39:44 -07:00
ecore_event_handler_add ( EDI_EVENT_TAB_CHANGED , _edi_tab_changed , NULL ) ;
ecore_event_handler_add ( EDI_EVENT_FILE_CHANGED , _edi_file_changed , NULL ) ;
2017-04-22 14:23:32 -07:00
ecore_event_handler_add ( EDI_EVENT_FILE_SAVED , _edi_file_saved , NULL ) ;
2018-11-25 09:05:16 -08:00
ecore_timer_add ( 1.0 , _edi_active_process_check_cb , NULL ) ;
2014-12-01 14:54:17 -08:00
2017-07-04 02:35:39 -07:00
ERR ( " Loaded project at %s " , path ) ;
evas_object_resize ( win , _edi_project_config - > gui . width * elm_config_scale_get ( ) ,
_edi_project_config - > gui . height * elm_config_scale_get ( ) ) ;
evas_object_show ( win ) ;
2014-11-12 15:43:18 -08:00
free ( path ) ;
2016-07-03 13:06:22 -07:00
return EINA_TRUE ;
}
void
edi_open_file ( const char * filepath )
{
// TODO we should make this window more functional (i.e. toolbar etc)
edi_project_set ( eina_environment_home_get ( ) ) ;
_edi_project_config_load ( ) ;
edi_mainview_open_window_path ( filepath ) ;
2014-02-12 12:56:20 -08:00
}
2015-01-10 09:43:12 -08:00
void
2014-06-29 15:54:29 -07:00
edi_close ( )
{
2017-04-28 14:01:04 -07:00
edi_debugpanel_stop ( ) ;
2014-06-29 15:54:29 -07:00
elm_exit ( ) ;
}
2015-05-19 14:28:05 -07:00
void
edi_open_url ( const char * url )
{
const char * format ;
char * cmd ;
format = " xdg-open \" %s \" " ;
cmd = malloc ( sizeof ( char ) * ( strlen ( format ) + strlen ( url ) - 1 ) ) ;
sprintf ( cmd , format , url ) ;
ecore_exe_run ( cmd , NULL ) ;
free ( cmd ) ;
}
2016-07-03 13:06:22 -07:00
Eina_Bool
edi_noproject ( )
{
return ! _edi_main_win ;
}
2014-12-21 15:32:14 -08:00
static Eina_Bool
_edi_log_init ( )
{
_edi_log_dom = eina_log_domain_register ( " edi " , EINA_COLOR_GREEN ) ;
if ( _edi_log_dom < 0 )
{
EINA_LOG_ERR ( " Edi can not create its log domain. " ) ;
return EINA_FALSE ;
}
return EINA_TRUE ;
}
static void
_edi_log_shutdown ( )
{
eina_log_domain_unregister ( _edi_log_dom ) ;
_edi_log_dom = - 1 ;
}
2014-02-12 12:56:20 -08:00
static const Ecore_Getopt optdesc = {
" edi " ,
2016-07-03 15:08:49 -07:00
" %prog [options] [project-dir] \n "
" or: %prog [options] [file] " ,
2014-02-12 12:56:20 -08:00
PACKAGE_VERSION ,
2019-12-22 06:42:06 -08:00
PACKAGE_COPYRIGHT ,
2015-06-04 00:40:43 -07:00
" GPLv2 " ,
" The Enlightened IDE " ,
2014-02-16 11:54:06 -08:00
EINA_TRUE ,
2014-02-12 12:56:20 -08:00
{
2016-08-26 07:13:54 -07:00
ECORE_GETOPT_STORE_TRUE ( ' c ' , " create " , " Create a new project " ) ,
2014-02-12 12:56:20 -08:00
ECORE_GETOPT_LICENSE ( ' L ' , " license " ) ,
ECORE_GETOPT_COPYRIGHT ( ' C ' , " copyright " ) ,
ECORE_GETOPT_VERSION ( ' V ' , " version " ) ,
ECORE_GETOPT_HELP ( ' h ' , " help " ) ,
ECORE_GETOPT_SENTINEL
}
} ;
EAPI_MAIN int
elm_main ( int argc EINA_UNUSED , char * * argv EINA_UNUSED )
{
int args ;
2016-08-26 07:13:54 -07:00
Eina_Bool create = EINA_FALSE , quit_option = EINA_FALSE ;
2014-02-16 11:54:06 -08:00
const char * project_path = NULL ;
2014-02-12 12:56:20 -08:00
Ecore_Getopt_Value values [ ] = {
2016-08-26 07:13:54 -07:00
ECORE_GETOPT_VALUE_BOOL ( create ) ,
2014-02-12 12:56:20 -08:00
ECORE_GETOPT_VALUE_BOOL ( quit_option ) ,
ECORE_GETOPT_VALUE_BOOL ( quit_option ) ,
ECORE_GETOPT_VALUE_BOOL ( quit_option ) ,
ECORE_GETOPT_VALUE_BOOL ( quit_option ) ,
ECORE_GETOPT_VALUE_NONE
} ;
# if ENABLE_NLS
setlocale ( LC_ALL , " " ) ;
bindtextdomain ( PACKAGE , LOCALEDIR ) ;
bind_textdomain_codeset ( PACKAGE , " UTF-8 " ) ;
textdomain ( PACKAGE ) ;
# endif
2014-12-01 14:54:17 -08:00
if ( ! _edi_config_init ( ) )
goto config_error ;
2014-02-12 12:56:20 -08:00
edi_init ( ) ;
2014-12-21 15:32:14 -08:00
if ( ! _edi_log_init ( ) )
goto end ;
2014-02-12 12:56:20 -08:00
args = ecore_getopt_parse ( & optdesc , values , argc , argv ) ;
2017-10-03 06:11:50 -07:00
if ( quit_option )
2014-02-12 12:56:20 -08:00
{
2017-10-04 08:53:28 -07:00
goto end ;
2014-02-12 12:56:20 -08:00
}
2017-10-03 06:11:50 -07:00
else if ( args < 0 )
2014-02-12 12:56:20 -08:00
{
2017-10-03 06:11:50 -07:00
CRIT ( " Could not parse arguments. " ) ;
2014-02-15 16:31:10 -08:00
goto end ;
2014-02-12 12:56:20 -08:00
}
2014-02-16 11:54:06 -08:00
if ( args < argc )
{
2014-10-22 14:41:23 -07:00
project_path = argv [ args ] ;
2014-02-16 11:54:06 -08:00
}
2015-02-02 15:52:04 -08:00
/* tell elm about our app so it can figure out where to get files */
elm_app_compile_bin_dir_set ( PACKAGE_BIN_DIR ) ;
elm_app_compile_lib_dir_set ( PACKAGE_LIB_DIR ) ;
elm_app_compile_data_dir_set ( PACKAGE_DATA_DIR ) ;
2014-02-12 12:56:20 -08:00
elm_app_info_set ( elm_main , " edi " , " images/edi.png " ) ;
2017-04-07 15:39:44 -07:00
EDI_EVENT_TAB_CHANGED = ecore_event_type_new ( ) ;
EDI_EVENT_FILE_CHANGED = ecore_event_type_new ( ) ;
2017-04-22 14:23:32 -07:00
EDI_EVENT_FILE_SAVED = ecore_event_type_new ( ) ;
2017-04-07 15:39:44 -07:00
2014-06-29 15:54:29 -07:00
if ( ! project_path )
{
2016-08-26 07:13:54 -07:00
if ( create )
edi_welcome_create_show ( ) ;
else if ( ! edi_welcome_show ( ) )
2014-06-29 15:54:29 -07:00
goto end ;
}
2016-07-03 13:06:22 -07:00
else if ( ! ecore_file_is_dir ( project_path ) )
{
2017-05-13 15:29:46 -07:00
const char * mime ;
2019-12-20 10:00:57 -08:00
mime = edi_mime_type_get ( project_path ) ;
2017-05-13 15:29:46 -07:00
if ( ! edi_content_provider_for_mime_get ( mime ) )
{
2017-09-11 13:06:22 -07:00
fprintf ( stderr , _ ( " Could not open file of unsupported mime type (%s) \n " ) , mime ) ;
2017-05-13 15:29:46 -07:00
goto end ;
}
2016-07-03 13:06:22 -07:00
edi_open_file ( project_path ) ;
}
else if ( ! ( edi_open ( project_path ) ) )
2014-02-12 12:56:20 -08:00
goto end ;
elm_run ( ) ;
end :
2014-12-21 15:32:14 -08:00
_edi_log_shutdown ( ) ;
2014-02-12 12:56:20 -08:00
elm_shutdown ( ) ;
2017-06-06 17:45:44 -07:00
edi_scm_shutdown ( ) ;
2014-12-01 14:54:17 -08:00
edi_shutdown ( ) ;
config_error :
_edi_config_shutdown ( ) ;
2014-02-12 12:56:20 -08:00
return 0 ;
}
ELM_MAIN ( )