Make stop button only apply for killing running programs.
Disable build commands when building is in progress. Make build_menu_update() detect how to call set_stop_button(). Make build_menu_update() also update the LaTeX build menu. Make build keybindings only active when the equivalent menu item is also active. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@1036 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
d807020f50
commit
e39cf19730
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
2006-11-29 Nick Treleaven <nick.treleaven@btinternet.com>
|
||||||
|
|
||||||
|
* src/build.c, src/build.h, src/keybindings.c, src/filetypes.c,
|
||||||
|
src/filetypes.h:
|
||||||
|
Make stop button only apply for killing running programs.
|
||||||
|
Disable build commands when building is in progress.
|
||||||
|
Make build_menu_update() detect how to call set_stop_button().
|
||||||
|
Make build_menu_update() also update the LaTeX build menu.
|
||||||
|
Make build keybindings only active when the equivalent menu item
|
||||||
|
is also active.
|
||||||
|
|
||||||
|
|
||||||
2006-11-27 Nick Treleaven <nick.treleaven@btinternet.com>
|
2006-11-27 Nick Treleaven <nick.treleaven@btinternet.com>
|
||||||
|
|
||||||
* src/build.c:
|
* src/build.c:
|
||||||
|
263
src/build.c
263
src/build.c
@ -48,6 +48,12 @@
|
|||||||
|
|
||||||
BuildInfo build_info = {GBO_COMPILE, 0, NULL, GEANY_FILETYPES_ALL, NULL};
|
BuildInfo build_info = {GBO_COMPILE, 0, NULL, GEANY_FILETYPES_ALL, NULL};
|
||||||
|
|
||||||
|
static struct
|
||||||
|
{
|
||||||
|
GPid pid;
|
||||||
|
gint file_type_id;
|
||||||
|
} run_info = {0, GEANY_FILETYPES_ALL};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
LATEX_CMD_TO_DVI,
|
LATEX_CMD_TO_DVI,
|
||||||
@ -65,9 +71,11 @@ static void on_make_target_dialog_response(GtkDialog *dialog, gint response, gpo
|
|||||||
static void on_make_target_entry_activate(GtkEntry *entry, gpointer user_data);
|
static void on_make_target_entry_activate(GtkEntry *entry, gpointer user_data);
|
||||||
static void set_stop_button(gboolean stop);
|
static void set_stop_button(gboolean stop);
|
||||||
static void build_exit_cb(GPid child_pid, gint status, gpointer user_data);
|
static void build_exit_cb(GPid child_pid, gint status, gpointer user_data);
|
||||||
|
static void run_exit_cb(GPid child_pid, gint status, gpointer user_data);
|
||||||
static void free_pointers(gpointer first, ...);
|
static void free_pointers(gpointer first, ...);
|
||||||
|
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
static void kill_process(gint pid);
|
static void kill_process(GPid *pid);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void build_finalize()
|
void build_finalize()
|
||||||
@ -116,8 +124,7 @@ GPid build_view_tex_file(gint idx, gint mode)
|
|||||||
|
|
||||||
if (idx < 0 || doc_list[idx].file_name == NULL) return (GPid) 1;
|
if (idx < 0 || doc_list[idx].file_name == NULL) return (GPid) 1;
|
||||||
|
|
||||||
build_info.file_type_id = GEANY_FILETYPES_LATEX;
|
run_info.file_type_id = GEANY_FILETYPES_LATEX;
|
||||||
build_info.type = GBO_RUN;
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
script_name = g_strdup("./geany_run_script.bat");
|
script_name = g_strdup("./geany_run_script.bat");
|
||||||
@ -206,7 +213,7 @@ GPid build_view_tex_file(gint idx, gint mode)
|
|||||||
|
|
||||||
|
|
||||||
if (! g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
|
if (! g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
|
||||||
NULL, NULL, &(build_info.pid), NULL, NULL, NULL, &error))
|
NULL, NULL, &(run_info.pid), NULL, NULL, NULL, &error))
|
||||||
{
|
{
|
||||||
geany_debug("g_spawn_async_with_pipes() failed: %s", error->message);
|
geany_debug("g_spawn_async_with_pipes() failed: %s", error->message);
|
||||||
msgwin_status_add(_("Process failed (%s)"), error->message);
|
msgwin_status_add(_("Process failed (%s)"), error->message);
|
||||||
@ -220,11 +227,11 @@ GPid build_view_tex_file(gint idx, gint mode)
|
|||||||
return (GPid) 0;
|
return (GPid) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (build_info.pid > 0)
|
if (run_info.pid > 0)
|
||||||
{
|
{
|
||||||
//setpgid(0, getppid());
|
//setpgid(0, getppid());
|
||||||
g_child_watch_add(build_info.pid, (GChildWatchFunc) build_exit_cb, NULL);
|
g_child_watch_add(run_info.pid, (GChildWatchFunc) run_exit_cb, NULL);
|
||||||
set_stop_button(TRUE);
|
build_menu_update(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
free_pointers(executable, view_file, locale_filename, cmd_string, locale_cmd_string,
|
free_pointers(executable, view_file, locale_filename, cmd_string, locale_cmd_string,
|
||||||
@ -232,7 +239,7 @@ GPid build_view_tex_file(gint idx, gint mode)
|
|||||||
g_strfreev(argv);
|
g_strfreev(argv);
|
||||||
g_strfreev(term_argv);
|
g_strfreev(term_argv);
|
||||||
|
|
||||||
return build_info.pid;
|
return run_info.pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -439,7 +446,7 @@ static GPid build_spawn_cmd(gint idx, gchar **cmd)
|
|||||||
if (build_info.pid > 0)
|
if (build_info.pid > 0)
|
||||||
{
|
{
|
||||||
g_child_watch_add(build_info.pid, (GChildWatchFunc) build_exit_cb, NULL);
|
g_child_watch_add(build_info.pid, (GChildWatchFunc) build_exit_cb, NULL);
|
||||||
set_stop_button(TRUE);
|
build_menu_update(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use GIOChannels to monitor stdout and stderr
|
// use GIOChannels to monitor stdout and stderr
|
||||||
@ -479,8 +486,7 @@ GPid build_run_cmd(gint idx)
|
|||||||
|
|
||||||
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_name == NULL) return (GPid) 1;
|
if (! DOC_IDX_VALID(idx) || doc_list[idx].file_name == NULL) return (GPid) 1;
|
||||||
|
|
||||||
build_info.file_type_id = FILETYPE_ID(doc_list[idx].file_type);
|
run_info.file_type_id = FILETYPE_ID(doc_list[idx].file_type);
|
||||||
build_info.type = GBO_RUN;
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
script_name = g_strdup("./geany_run_script.bat");
|
script_name = g_strdup("./geany_run_script.bat");
|
||||||
@ -599,7 +605,7 @@ GPid build_run_cmd(gint idx)
|
|||||||
argv[term_argv_len + 2] = NULL;
|
argv[term_argv_len + 2] = NULL;
|
||||||
|
|
||||||
if (! g_spawn_async_with_pipes(working_dir, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
|
if (! g_spawn_async_with_pipes(working_dir, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD,
|
||||||
NULL, NULL, &(build_info.pid), NULL, NULL, NULL, &error))
|
NULL, NULL, &(run_info.pid), NULL, NULL, NULL, &error))
|
||||||
{
|
{
|
||||||
geany_debug("g_spawn_async_with_pipes() failed: %s", error->message);
|
geany_debug("g_spawn_async_with_pipes() failed: %s", error->message);
|
||||||
msgwin_status_add(_("Process failed (%s)"), error->message);
|
msgwin_status_add(_("Process failed (%s)"), error->message);
|
||||||
@ -610,11 +616,11 @@ GPid build_run_cmd(gint idx)
|
|||||||
goto free_strings;
|
goto free_strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
result_id = build_info.pid; // g_spawn was successful, result is child process id
|
result_id = run_info.pid; // g_spawn was successful, result is child process id
|
||||||
if (build_info.pid > 0)
|
if (run_info.pid > 0)
|
||||||
{
|
{
|
||||||
g_child_watch_add(build_info.pid, (GChildWatchFunc) build_exit_cb, NULL);
|
g_child_watch_add(run_info.pid, (GChildWatchFunc) run_exit_cb, NULL);
|
||||||
set_stop_button(TRUE);
|
build_menu_update(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
free_strings:
|
free_strings:
|
||||||
@ -705,8 +711,6 @@ static void show_build_result_message(gboolean failure)
|
|||||||
|
|
||||||
static void build_exit_cb(GPid child_pid, gint status, gpointer user_data)
|
static void build_exit_cb(GPid child_pid, gint status, gpointer user_data)
|
||||||
{
|
{
|
||||||
if (build_info.type != GBO_RUN) // not necessary when executing a file
|
|
||||||
{
|
|
||||||
#ifdef G_OS_UNIX
|
#ifdef G_OS_UNIX
|
||||||
gboolean failure = FALSE;
|
gboolean failure = FALSE;
|
||||||
|
|
||||||
@ -726,14 +730,23 @@ static void build_exit_cb(GPid child_pid, gint status, gpointer user_data)
|
|||||||
}
|
}
|
||||||
show_build_result_message(failure);
|
show_build_result_message(failure);
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
if (build_info.type != GBO_RUN) utils_beep();
|
utils_beep();
|
||||||
g_spawn_close_pid(child_pid);
|
g_spawn_close_pid(child_pid);
|
||||||
|
|
||||||
build_info.pid = 0;
|
build_info.pid = 0;
|
||||||
|
// enable build items again
|
||||||
|
build_menu_update(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void run_exit_cb(GPid child_pid, gint status, gpointer user_data)
|
||||||
|
{
|
||||||
|
g_spawn_close_pid(child_pid);
|
||||||
|
|
||||||
|
run_info.pid = 0;
|
||||||
// reset the stop button and menu item to the original meaning
|
// reset the stop button and menu item to the original meaning
|
||||||
set_stop_button(FALSE);
|
build_menu_update(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -922,6 +935,7 @@ static GtkWidget *create_build_menu_tex()
|
|||||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
|
||||||
g_signal_connect((gpointer) item, "activate",
|
g_signal_connect((gpointer) item, "activate",
|
||||||
G_CALLBACK(on_build_tex_activate), GINT_TO_POINTER(LATEX_CMD_TO_DVI));
|
G_CALLBACK(on_build_tex_activate), GINT_TO_POINTER(LATEX_CMD_TO_DVI));
|
||||||
|
ft->menu_items->item_compile = item;
|
||||||
|
|
||||||
// PDF
|
// PDF
|
||||||
item = gtk_image_menu_item_new_with_mnemonic(_("LaTeX -> PDF"));
|
item = gtk_image_menu_item_new_with_mnemonic(_("LaTeX -> PDF"));
|
||||||
@ -936,6 +950,7 @@ static GtkWidget *create_build_menu_tex()
|
|||||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
|
||||||
g_signal_connect((gpointer) item, "activate",
|
g_signal_connect((gpointer) item, "activate",
|
||||||
G_CALLBACK(on_build_tex_activate), GINT_TO_POINTER(LATEX_CMD_TO_PDF));
|
G_CALLBACK(on_build_tex_activate), GINT_TO_POINTER(LATEX_CMD_TO_PDF));
|
||||||
|
ft->menu_items->item_link = item;
|
||||||
|
|
||||||
if (item != NULL)
|
if (item != NULL)
|
||||||
{
|
{
|
||||||
@ -1003,6 +1018,7 @@ static GtkWidget *create_build_menu_tex()
|
|||||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
|
||||||
g_signal_connect((gpointer) item, "activate",
|
g_signal_connect((gpointer) item, "activate",
|
||||||
G_CALLBACK(on_build_execute_activate), GINT_TO_POINTER(LATEX_CMD_VIEW_PDF));
|
G_CALLBACK(on_build_execute_activate), GINT_TO_POINTER(LATEX_CMD_VIEW_PDF));
|
||||||
|
ft->menu_items->item_exec2 = item;
|
||||||
|
|
||||||
// separator
|
// separator
|
||||||
separator = gtk_separator_menu_item_new();
|
separator = gtk_separator_menu_item_new();
|
||||||
@ -1022,7 +1038,8 @@ static GtkWidget *create_build_menu_tex()
|
|||||||
image = gtk_image_new_from_stock("gtk-preferences", GTK_ICON_SIZE_MENU);
|
image = gtk_image_new_from_stock("gtk-preferences", GTK_ICON_SIZE_MENU);
|
||||||
gtk_widget_show(image);
|
gtk_widget_show(image);
|
||||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image);
|
||||||
g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_tex_arguments_activate), NULL);
|
g_signal_connect((gpointer) item, "activate",
|
||||||
|
G_CALLBACK(on_build_arguments_activate), ft);
|
||||||
|
|
||||||
gtk_window_add_accel_group(GTK_WINDOW(app->window), accel_group);
|
gtk_window_add_accel_group(GTK_WINDOW(app->window), accel_group);
|
||||||
|
|
||||||
@ -1045,9 +1062,13 @@ static gboolean is_c_header(const gchar *fname)
|
|||||||
void build_menu_update(gint idx)
|
void build_menu_update(gint idx)
|
||||||
{
|
{
|
||||||
filetype *ft;
|
filetype *ft;
|
||||||
gboolean have_path;
|
gboolean have_path, can_build, can_make;
|
||||||
|
|
||||||
if (idx == -1 || doc_list[idx].file_type == NULL)
|
if (idx == -1)
|
||||||
|
idx = document_get_cur_idx();
|
||||||
|
if (idx == -1 ||
|
||||||
|
(FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_ALL &&
|
||||||
|
doc_list[idx].file_name == NULL))
|
||||||
{
|
{
|
||||||
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_build1"), FALSE);
|
gtk_widget_set_sensitive(lookup_widget(app->window, "menu_build1"), FALSE);
|
||||||
gtk_menu_item_remove_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")));
|
gtk_menu_item_remove_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")));
|
||||||
@ -1066,60 +1087,106 @@ void build_menu_update(gint idx)
|
|||||||
ft->menu_items->can_link = FALSE;
|
ft->menu_items->can_link = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gtk_menu_item_remove_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")));
|
|
||||||
|
|
||||||
if (ft->menu_items->menu == NULL)
|
if (ft->menu_items->menu == NULL)
|
||||||
{
|
{
|
||||||
ft->menu_items->menu = (ft->id == GEANY_FILETYPES_LATEX) ?
|
ft->menu_items->menu = (ft->id == GEANY_FILETYPES_LATEX) ?
|
||||||
create_build_menu_tex() : create_build_menu_gen(idx);
|
create_build_menu_tex() : create_build_menu_gen(idx);
|
||||||
g_object_ref((gpointer)ft->menu_items->menu); // to hold it after removing
|
g_object_ref((gpointer)ft->menu_items->menu); // to hold it after removing
|
||||||
}
|
}
|
||||||
|
/* Note: don't remove the submenu first because it can now cause an X hang if
|
||||||
|
* the menu is already open when called from build_exit_cb(). */
|
||||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")),
|
gtk_menu_item_set_submenu(GTK_MENU_ITEM(lookup_widget(app->window, "menu_build1")),
|
||||||
ft->menu_items->menu);
|
ft->menu_items->menu);
|
||||||
|
|
||||||
have_path = (doc_list[idx].file_name != NULL);
|
have_path = (doc_list[idx].file_name != NULL);
|
||||||
// update the Make items
|
|
||||||
if (ft->menu_items->item_make_all != NULL)
|
|
||||||
gtk_widget_set_sensitive(ft->menu_items->item_make_all, have_path);
|
|
||||||
if (ft->menu_items->item_make_custom != NULL)
|
|
||||||
gtk_widget_set_sensitive(ft->menu_items->item_make_custom, have_path);
|
|
||||||
if (ft->menu_items->item_make_object != NULL)
|
|
||||||
gtk_widget_set_sensitive(ft->menu_items->item_make_object, have_path);
|
|
||||||
|
|
||||||
switch (ft->id)
|
can_make = have_path && build_info.pid <= 1;
|
||||||
{
|
|
||||||
case GEANY_FILETYPES_LATEX:
|
// disable compile and link for C/C++ header files
|
||||||
{
|
if (ft->id == GEANY_FILETYPES_C || ft->id == GEANY_FILETYPES_CPP)
|
||||||
gtk_widget_set_sensitive(app->compile_button, have_path && ft->menu_items->can_compile);
|
can_build = can_make && ! is_c_header(doc_list[idx].file_name);
|
||||||
gtk_widget_set_sensitive(app->run_button, have_path && ft->menu_items->can_exec);
|
else
|
||||||
break;
|
can_build = can_make;
|
||||||
}
|
|
||||||
case GEANY_FILETYPES_C: // intended fallthrough, C and C++ behave equal
|
if (ft->menu_items->can_compile)
|
||||||
case GEANY_FILETYPES_CPP:
|
gtk_widget_set_sensitive(ft->menu_items->item_compile, can_build);
|
||||||
{
|
if (ft->menu_items->can_link)
|
||||||
|
gtk_widget_set_sensitive(ft->menu_items->item_link, can_build);
|
||||||
|
if (ft->menu_items->item_make_all)
|
||||||
|
gtk_widget_set_sensitive(ft->menu_items->item_make_all, can_make);
|
||||||
|
if (ft->menu_items->item_make_custom)
|
||||||
|
gtk_widget_set_sensitive(ft->menu_items->item_make_custom, can_make);
|
||||||
|
if (ft->menu_items->item_make_object)
|
||||||
|
gtk_widget_set_sensitive(ft->menu_items->item_make_object, can_make);
|
||||||
if (ft->menu_items->can_exec)
|
if (ft->menu_items->can_exec)
|
||||||
|
{
|
||||||
|
gboolean can_run = have_path && run_info.pid <= 1;
|
||||||
|
|
||||||
|
/* can_run only applies item_exec2
|
||||||
|
* item_exec is enabled for both run and stop commands */
|
||||||
|
if (ft->menu_items->item_exec)
|
||||||
gtk_widget_set_sensitive(ft->menu_items->item_exec, have_path);
|
gtk_widget_set_sensitive(ft->menu_items->item_exec, have_path);
|
||||||
|
if (ft->menu_items->item_exec2)
|
||||||
|
gtk_widget_set_sensitive(ft->menu_items->item_exec2, can_run);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_set_sensitive(app->compile_button, can_build && ft->menu_items->can_compile);
|
||||||
gtk_widget_set_sensitive(app->run_button, have_path && ft->menu_items->can_exec);
|
gtk_widget_set_sensitive(app->run_button, have_path && ft->menu_items->can_exec);
|
||||||
|
|
||||||
// compile and link are disabled for header files
|
// show the stop command if a program is running, otherwise show run command
|
||||||
have_path = have_path && ! is_c_header(doc_list[idx].file_name);
|
set_stop_button(run_info.pid > 1);
|
||||||
gtk_widget_set_sensitive(app->compile_button, have_path && ft->menu_items->can_compile);
|
}
|
||||||
if (ft->menu_items->can_compile)
|
|
||||||
gtk_widget_set_sensitive(ft->menu_items->item_compile, have_path);
|
|
||||||
if (ft->menu_items->can_link)
|
// Call build_menu_update() instead of calling this directly.
|
||||||
gtk_widget_set_sensitive(ft->menu_items->item_link, have_path);
|
static void set_stop_button(gboolean stop)
|
||||||
break;
|
{
|
||||||
}
|
GtkStockItem sitem;
|
||||||
default:
|
GtkWidget *menuitem =
|
||||||
|
filetypes[run_info.file_type_id]->menu_items->item_exec;
|
||||||
|
|
||||||
|
if (stop && utils_str_equal(
|
||||||
|
gtk_tool_button_get_stock_id(GTK_TOOL_BUTTON(app->run_button)), "gtk-stop")) return;
|
||||||
|
if (! stop && utils_str_equal(
|
||||||
|
gtk_tool_button_get_stock_id(GTK_TOOL_BUTTON(app->run_button)), "gtk-execute")) return;
|
||||||
|
|
||||||
|
// use the run button also as stop button
|
||||||
|
if (stop)
|
||||||
{
|
{
|
||||||
gtk_widget_set_sensitive(app->compile_button, have_path && ft->menu_items->can_compile);
|
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(app->run_button), "gtk-stop");
|
||||||
gtk_widget_set_sensitive(app->run_button, have_path && ft->menu_items->can_exec);
|
|
||||||
if (ft->menu_items->can_compile)
|
if (menuitem != NULL)
|
||||||
gtk_widget_set_sensitive(ft->menu_items->item_compile, have_path);
|
{
|
||||||
if (ft->menu_items->can_link)
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
|
||||||
gtk_widget_set_sensitive(ft->menu_items->item_link, have_path);
|
gtk_image_new_from_stock("gtk-stop", GTK_ICON_SIZE_MENU));
|
||||||
if (ft->menu_items->can_exec)
|
gtk_stock_lookup("gtk-stop", &sitem);
|
||||||
gtk_widget_set_sensitive(ft->menu_items->item_exec, have_path);
|
gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))),
|
||||||
|
sitem.label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(app->run_button), "gtk-execute");
|
||||||
|
|
||||||
|
if (menuitem != NULL)
|
||||||
|
{
|
||||||
|
// LaTeX hacks ;-(
|
||||||
|
if (run_info.file_type_id == GEANY_FILETYPES_LATEX)
|
||||||
|
{
|
||||||
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
|
||||||
|
gtk_image_new_from_stock("gtk-find", GTK_ICON_SIZE_MENU));
|
||||||
|
gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))),
|
||||||
|
LATEX_VIEW_DVI_LABEL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
|
||||||
|
gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_MENU));
|
||||||
|
|
||||||
|
gtk_stock_lookup("gtk-execute", &sitem);
|
||||||
|
gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))),
|
||||||
|
sitem.label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1219,11 +1286,11 @@ on_build_execute_activate (GtkMenuItem *menuitem,
|
|||||||
gint idx = document_get_cur_idx();
|
gint idx = document_get_cur_idx();
|
||||||
|
|
||||||
// make the process "stopable"
|
// make the process "stopable"
|
||||||
if (build_info.pid > (GPid) 1)
|
if (run_info.pid > (GPid) 1)
|
||||||
{
|
{
|
||||||
// on Windows there is no PID returned (resp. it is a handle), currently unsupported
|
// on Windows there is no PID returned (resp. it is a handle), currently unsupported
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
kill_process(build_info.pid);
|
kill_process(&run_info.pid);
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1261,15 +1328,10 @@ void
|
|||||||
on_build_arguments_activate (GtkMenuItem *menuitem,
|
on_build_arguments_activate (GtkMenuItem *menuitem,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
dialogs_show_includes_arguments_gen();
|
if (user_data && FILETYPE_ID((filetype*) user_data) == GEANY_FILETYPES_LATEX)
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
on_build_tex_arguments_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
|
||||||
dialogs_show_includes_arguments_tex();
|
dialogs_show_includes_arguments_tex();
|
||||||
|
else
|
||||||
|
dialogs_show_includes_arguments_gen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1301,57 +1363,8 @@ on_make_target_entry_activate (GtkEntry *entry,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void set_stop_button(gboolean stop)
|
|
||||||
{
|
|
||||||
GtkStockItem sitem;
|
|
||||||
GtkWidget *menuitem =
|
|
||||||
filetypes[build_info.file_type_id]->menu_items->item_exec;
|
|
||||||
|
|
||||||
// use the run button also as stop button
|
|
||||||
if (stop)
|
|
||||||
{
|
|
||||||
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(app->run_button), "gtk-stop");
|
|
||||||
gtk_widget_set_sensitive(app->compile_button, FALSE);
|
|
||||||
if (menuitem != NULL)
|
|
||||||
{
|
|
||||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
|
|
||||||
gtk_image_new_from_stock("gtk-stop", GTK_ICON_SIZE_MENU));
|
|
||||||
gtk_stock_lookup("gtk-stop", &sitem);
|
|
||||||
gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))),
|
|
||||||
sitem.label);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(app->run_button), "gtk-execute");
|
|
||||||
gtk_widget_set_sensitive(app->compile_button, TRUE);
|
|
||||||
|
|
||||||
if (menuitem != NULL)
|
|
||||||
{
|
|
||||||
// LaTeX hacks ;-(
|
|
||||||
if (build_info.file_type_id == GEANY_FILETYPES_LATEX)
|
|
||||||
{
|
|
||||||
gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))),
|
|
||||||
LATEX_VIEW_DVI_LABEL);
|
|
||||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
|
|
||||||
gtk_image_new_from_stock("gtk-find", GTK_ICON_SIZE_MENU));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem),
|
|
||||||
gtk_image_new_from_stock("gtk-execute", GTK_ICON_SIZE_MENU));
|
|
||||||
|
|
||||||
gtk_stock_lookup("gtk-execute", &sitem);
|
|
||||||
gtk_label_set_text_with_mnemonic(GTK_LABEL(gtk_bin_get_child(GTK_BIN(menuitem))),
|
|
||||||
sitem.label);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef G_OS_WIN32
|
#ifndef G_OS_WIN32
|
||||||
static void kill_process(gint pid)
|
static void kill_process(GPid *pid)
|
||||||
{
|
{
|
||||||
/* SIGQUIT is not the best signal to use because it causes a core dump (this should not
|
/* SIGQUIT is not the best signal to use because it causes a core dump (this should not
|
||||||
* perforce necessary for just killing a process). But we must use a signal which we can
|
* perforce necessary for just killing a process). But we must use a signal which we can
|
||||||
@ -1360,15 +1373,15 @@ static void kill_process(gint pid)
|
|||||||
gint resultpg, result;
|
gint resultpg, result;
|
||||||
|
|
||||||
// sent SIGQUIT to all the processes to the processes' own process group
|
// sent SIGQUIT to all the processes to the processes' own process group
|
||||||
result = kill(pid, SIGQUIT);
|
result = kill(*pid, SIGQUIT);
|
||||||
resultpg = killpg(0, SIGQUIT);
|
resultpg = killpg(0, SIGQUIT);
|
||||||
|
|
||||||
if (result != 0 || resultpg != 0)
|
if (result != 0 || resultpg != 0)
|
||||||
msgwin_status_add(_("Process could not be stopped (%s)."), g_strerror(errno));
|
msgwin_status_add(_("Process could not be stopped (%s)."), g_strerror(errno));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
build_info.pid = 0;
|
*pid = 0;
|
||||||
set_stop_button(FALSE);
|
build_menu_update(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -30,8 +30,7 @@ typedef enum // Geany Build Options
|
|||||||
GBO_BUILD,
|
GBO_BUILD,
|
||||||
GBO_MAKE_ALL,
|
GBO_MAKE_ALL,
|
||||||
GBO_MAKE_CUSTOM,
|
GBO_MAKE_CUSTOM,
|
||||||
GBO_MAKE_OBJECT,
|
GBO_MAKE_OBJECT
|
||||||
GBO_RUN
|
|
||||||
} build_type;
|
} build_type;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -87,8 +86,4 @@ void
|
|||||||
on_build_arguments_activate (GtkMenuItem *menuitem,
|
on_build_arguments_activate (GtkMenuItem *menuitem,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
void
|
|
||||||
on_build_tex_arguments_activate (GtkMenuItem *menuitem,
|
|
||||||
gpointer user_data);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -867,20 +867,7 @@ void filetypes_free_types()
|
|||||||
if (filetypes[i]->menu_items->menu != NULL &&
|
if (filetypes[i]->menu_items->menu != NULL &&
|
||||||
GTK_IS_WIDGET(filetypes[i]->menu_items->menu))
|
GTK_IS_WIDGET(filetypes[i]->menu_items->menu))
|
||||||
gtk_widget_destroy(filetypes[i]->menu_items->menu);
|
gtk_widget_destroy(filetypes[i]->menu_items->menu);
|
||||||
/// TODO not necessary because they got freed with the menu?
|
g_free(filetypes[i]->menu_items);
|
||||||
/* if (filetypes[i]->menu_items->item_compile != NULL &&
|
|
||||||
GTK_IS_WIDGET(filetypes[i]->menu_items->item_compile))
|
|
||||||
gtk_widget_destroy(filetypes[i]->menu_items->item_compile);
|
|
||||||
if (filetypes[i]->menu_items->item_link != NULL &&
|
|
||||||
GTK_IS_WIDGET(filetypes[i]->menu_items->item_link))
|
|
||||||
gtk_widget_destroy(filetypes[i]->menu_items->item_link);
|
|
||||||
if (filetypes[i]->menu_items->item_exec != NULL &&
|
|
||||||
GTK_IS_WIDGET(filetypes[i]->menu_items->item_exec))
|
|
||||||
gtk_widget_destroy(filetypes[i]->menu_items->item_exec);
|
|
||||||
if (filetypes[i]->menu_items->item_make_object != NULL &&
|
|
||||||
GTK_IS_WIDGET(filetypes[i]->menu_items->item_make_object))
|
|
||||||
gtk_widget_destroy(filetypes[i]->menu_items->item_make_object);
|
|
||||||
*/ g_free(filetypes[i]->menu_items);
|
|
||||||
|
|
||||||
g_strfreev(filetypes[i]->pattern);
|
g_strfreev(filetypes[i]->pattern);
|
||||||
g_free(filetypes[i]);
|
g_free(filetypes[i]);
|
||||||
|
@ -75,6 +75,7 @@ struct build_menu_items
|
|||||||
GtkWidget *item_compile;
|
GtkWidget *item_compile;
|
||||||
GtkWidget *item_link;
|
GtkWidget *item_link;
|
||||||
GtkWidget *item_exec;
|
GtkWidget *item_exec;
|
||||||
|
GtkWidget *item_exec2;
|
||||||
GtkWidget *item_make_all;
|
GtkWidget *item_make_all;
|
||||||
GtkWidget *item_make_custom;
|
GtkWidget *item_make_custom;
|
||||||
GtkWidget *item_make_object;
|
GtkWidget *item_make_object;
|
||||||
|
@ -74,13 +74,7 @@ static void cb_func_menu_zoomout(guint key_id);
|
|||||||
static void cb_func_menu_replacetabs(guint key_id);
|
static void cb_func_menu_replacetabs(guint key_id);
|
||||||
static void cb_func_menu_foldall(guint key_id);
|
static void cb_func_menu_foldall(guint key_id);
|
||||||
static void cb_func_menu_unfoldall(guint key_id);
|
static void cb_func_menu_unfoldall(guint key_id);
|
||||||
static void cb_func_build_compile(guint key_id);
|
static void cb_func_build_action(guint key_id);
|
||||||
static void cb_func_build_link(guint key_id);
|
|
||||||
static void cb_func_build_make(guint key_id);
|
|
||||||
static void cb_func_build_makeowntarget(guint key_id);
|
|
||||||
static void cb_func_build_makeobject(guint key_id);
|
|
||||||
static void cb_func_build_run(guint key_id);
|
|
||||||
static void cb_func_build_run2(guint key_id);
|
|
||||||
static void cb_func_build_options(guint key_id);
|
static void cb_func_build_options(guint key_id);
|
||||||
static void cb_func_reloadtaglist(guint key_id);
|
static void cb_func_reloadtaglist(guint key_id);
|
||||||
static void cb_func_switch_editor(guint key_id);
|
static void cb_func_switch_editor(guint key_id);
|
||||||
@ -163,20 +157,20 @@ void keybindings_init(void)
|
|||||||
0, 0, "menu_foldall", _("Fold all"));
|
0, 0, "menu_foldall", _("Fold all"));
|
||||||
keys[GEANY_KEYS_MENU_UNFOLDALL] = fill(cb_func_menu_unfoldall,
|
keys[GEANY_KEYS_MENU_UNFOLDALL] = fill(cb_func_menu_unfoldall,
|
||||||
0, 0, "menu_unfoldall", _("Unfold all"));
|
0, 0, "menu_unfoldall", _("Unfold all"));
|
||||||
keys[GEANY_KEYS_BUILD_COMPILE] = fill(cb_func_build_compile,
|
keys[GEANY_KEYS_BUILD_COMPILE] = fill(cb_func_build_action,
|
||||||
GDK_F8, 0, "build_compile", _("Compile"));
|
GDK_F8, 0, "build_compile", _("Compile"));
|
||||||
keys[GEANY_KEYS_BUILD_LINK] = fill(cb_func_build_link,
|
keys[GEANY_KEYS_BUILD_LINK] = fill(cb_func_build_action,
|
||||||
GDK_F9, 0, "build_link", _("Build"));
|
GDK_F9, 0, "build_link", _("Build"));
|
||||||
keys[GEANY_KEYS_BUILD_MAKE] = fill(cb_func_build_make,
|
keys[GEANY_KEYS_BUILD_MAKE] = fill(cb_func_build_action,
|
||||||
GDK_F9, GDK_SHIFT_MASK, "build_make", _("Make all"));
|
GDK_F9, GDK_SHIFT_MASK, "build_make", _("Make all"));
|
||||||
keys[GEANY_KEYS_BUILD_MAKEOWNTARGET] = fill(cb_func_build_makeowntarget,
|
keys[GEANY_KEYS_BUILD_MAKEOWNTARGET] = fill(cb_func_build_action,
|
||||||
GDK_F9, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "build_makeowntarget",
|
GDK_F9, GDK_SHIFT_MASK | GDK_CONTROL_MASK, "build_makeowntarget",
|
||||||
_("Make custom target"));
|
_("Make custom target"));
|
||||||
keys[GEANY_KEYS_BUILD_MAKEOBJECT] = fill(cb_func_build_makeobject,
|
keys[GEANY_KEYS_BUILD_MAKEOBJECT] = fill(cb_func_build_action,
|
||||||
0, 0, "build_makeobject", _("Make object"));
|
0, 0, "build_makeobject", _("Make object"));
|
||||||
keys[GEANY_KEYS_BUILD_RUN] = fill(cb_func_build_run,
|
keys[GEANY_KEYS_BUILD_RUN] = fill(cb_func_build_action,
|
||||||
GDK_F5, 0, "build_run", _("Run"));
|
GDK_F5, 0, "build_run", _("Run"));
|
||||||
keys[GEANY_KEYS_BUILD_RUN2] = fill(cb_func_build_run2,
|
keys[GEANY_KEYS_BUILD_RUN2] = fill(cb_func_build_action,
|
||||||
0, 0, "build_run2", _("Run (alternative command)"));
|
0, 0, "build_run2", _("Run (alternative command)"));
|
||||||
keys[GEANY_KEYS_BUILD_OPTIONS] = fill(cb_func_build_options,
|
keys[GEANY_KEYS_BUILD_OPTIONS] = fill(cb_func_build_options,
|
||||||
0, 0, "build_options", _("Build options"));
|
0, 0, "build_options", _("Build options"));
|
||||||
@ -571,71 +565,70 @@ static void cb_func_menu_unfoldall(G_GNUC_UNUSED guint key_id)
|
|||||||
document_unfold_all(idx);
|
document_unfold_all(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cb_func_build_compile(G_GNUC_UNUSED guint key_id)
|
static void cb_func_build_action(guint key_id)
|
||||||
{
|
{
|
||||||
gint idx = document_get_cur_idx();
|
gint idx = document_get_cur_idx();
|
||||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
GtkWidget *item;
|
||||||
if (doc_list[idx].file_type->menu_items->can_compile && doc_list[idx].file_name != NULL)
|
filetype *ft;
|
||||||
on_build_compile_activate(NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cb_func_build_link(G_GNUC_UNUSED guint key_id)
|
if (! DOC_IDX_VALID(idx)) return;
|
||||||
{
|
|
||||||
gint idx = document_get_cur_idx();
|
|
||||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
|
||||||
if (doc_list[idx].file_type->menu_items->can_link && doc_list[idx].file_name != NULL)
|
|
||||||
on_build_build_activate(NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cb_func_build_make(G_GNUC_UNUSED guint key_id)
|
ft = doc_list[idx].file_type;
|
||||||
{
|
if (! ft || ! ft->menu_items) return;
|
||||||
gint idx = document_get_cur_idx();
|
|
||||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
|
||||||
if (doc_list[idx].file_name != NULL)
|
|
||||||
on_build_make_activate(NULL, GINT_TO_POINTER(GBO_MAKE_ALL));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cb_func_build_makeowntarget(G_GNUC_UNUSED guint key_id)
|
switch (key_id)
|
||||||
{
|
{
|
||||||
gint idx = document_get_cur_idx();
|
case GEANY_KEYS_BUILD_COMPILE:
|
||||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
item = ft->menu_items->item_compile;
|
||||||
if (doc_list[idx].file_name != NULL)
|
break;
|
||||||
on_build_make_activate(NULL, GINT_TO_POINTER(GBO_MAKE_CUSTOM));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cb_func_build_makeobject(G_GNUC_UNUSED guint key_id)
|
case GEANY_KEYS_BUILD_LINK:
|
||||||
{
|
item = ft->menu_items->item_link;
|
||||||
gint idx = document_get_cur_idx();
|
break;
|
||||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
|
||||||
if (doc_list[idx].file_name != NULL)
|
|
||||||
on_build_make_activate(NULL, GINT_TO_POINTER(GBO_MAKE_OBJECT));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cb_func_build_run(G_GNUC_UNUSED guint key_id)
|
case GEANY_KEYS_BUILD_MAKE:
|
||||||
{
|
item = ft->menu_items->item_make_all;
|
||||||
gint idx = document_get_cur_idx();
|
break;
|
||||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
|
||||||
if (doc_list[idx].file_type->menu_items->can_exec && doc_list[idx].file_name != NULL)
|
|
||||||
on_build_execute_activate(NULL, GINT_TO_POINTER(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void cb_func_build_run2(G_GNUC_UNUSED guint key_id)
|
case GEANY_KEYS_BUILD_MAKEOWNTARGET:
|
||||||
{
|
item = ft->menu_items->item_make_custom;
|
||||||
gint idx = document_get_cur_idx();
|
break;
|
||||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
|
||||||
if (doc_list[idx].file_type->menu_items->can_exec && doc_list[idx].file_name != NULL)
|
case GEANY_KEYS_BUILD_MAKEOBJECT:
|
||||||
on_build_execute_activate(NULL, GINT_TO_POINTER(1));
|
item = ft->menu_items->item_make_object;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GEANY_KEYS_BUILD_RUN:
|
||||||
|
item = ft->menu_items->item_exec;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GEANY_KEYS_BUILD_RUN2:
|
||||||
|
item = ft->menu_items->item_exec2;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
item = NULL;
|
||||||
|
}
|
||||||
|
if (item && GTK_WIDGET_IS_SENSITIVE(item))
|
||||||
|
gtk_menu_item_activate(GTK_MENU_ITEM(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cb_func_build_options(G_GNUC_UNUSED guint key_id)
|
static void cb_func_build_options(G_GNUC_UNUSED guint key_id)
|
||||||
{
|
{
|
||||||
gint idx = document_get_cur_idx();
|
gint idx = document_get_cur_idx();
|
||||||
if (idx == -1 || ! doc_list[idx].is_valid) return;
|
document *doc;
|
||||||
if ((doc_list[idx].file_type->menu_items->can_compile ||
|
filetype *ft;
|
||||||
doc_list[idx].file_type->menu_items->can_link ||
|
|
||||||
doc_list[idx].file_type->menu_items->can_exec) &&
|
if (! DOC_IDX_VALID(idx)) return;
|
||||||
doc_list[idx].file_name != NULL)
|
doc = &doc_list[idx];
|
||||||
on_build_arguments_activate(NULL, NULL);
|
ft = doc->file_type;
|
||||||
|
if (! ft || ! ft->menu_items) return;
|
||||||
|
if ((ft->menu_items->can_compile ||
|
||||||
|
ft->menu_items->can_link ||
|
||||||
|
ft->menu_items->can_exec) &&
|
||||||
|
(doc->file_name != NULL ||
|
||||||
|
FILETYPE_ID(ft) != GEANY_FILETYPES_ALL))
|
||||||
|
on_build_arguments_activate(NULL, ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cb_func_reloadtaglist(G_GNUC_UNUSED guint key_id)
|
static void cb_func_reloadtaglist(G_GNUC_UNUSED guint key_id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user