Revision: 811 http://svn.sourceforge.net/geany/?rev=811&view=rev Author: eht16 Date: 2006-09-11 04:13:36 -0700 (Mon, 11 Sep 2006)
Log Message: ----------- Implemented Run command (from the build menu) under Windows, the other commands will follow somewhen.
Modified Paths: -------------- trunk/src/build.c trunk/src/callbacks.c trunk/src/main.c trunk/src/prefs.c trunk/src/ui_utils.c
Modified: trunk/src/build.c =================================================================== --- trunk/src/build.c 2006-09-11 07:41:37 UTC (rev 810) +++ trunk/src/build.c 2006-09-11 11:13:36 UTC (rev 811) @@ -104,6 +104,12 @@ // try convert in locale locale_cmd_string = utils_get_locale_from_utf8(cmd_string);
+#ifdef G_OS_WIN32 + argv = NULL; + child_pid = (GPid) 0; + + if (! g_spawn_command_line_async(locale_cmd_string, &error)) +#else argv = g_new0(gchar *, 4); argv[0] = g_strdup("/bin/sh"); argv[1] = g_strdup("-c"); @@ -112,6 +118,7 @@
if (! g_spawn_async_with_pipes(NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &child_pid, NULL, NULL, NULL, &error)) +#endif { geany_debug("g_spawn_async_with_pipes() failed: %s", error->message); msgwin_status_add(_("Process failed (%s)"), error->message); @@ -120,6 +127,9 @@ g_free(executable); g_free(locale_filename); g_free(cmd_string); +#ifdef G_OS_WIN32 + g_free(locale_cmd_string); +#endif g_strfreev(argv); g_error_free(error); error = NULL; @@ -345,7 +355,11 @@
if (idx < 0 || doc_list[idx].file_name == NULL) return (GPid) 1;
+#ifdef G_OS_WIN32 + script_name = g_strdup("./geany_run_script.bat"); +#else script_name = g_strdup("./geany_run_script.sh"); +#endif
locale_filename = utils_get_locale_from_utf8(doc_list[idx].file_name);
@@ -355,22 +369,37 @@ term_argv_len = g_strv_length(term_argv);
long_executable = utils_remove_ext_from_filename(locale_filename); +#ifdef G_OS_WIN32 + long_executable = g_strconcat(long_executable, ".exe", NULL); +#endif
// only check for existing executable, if executable is required by %e if (strstr(doc_list[idx].file_type->programs->run_cmd, "%e") != NULL) { // add .class extension for JAVA source files (only for stat) if (doc_list[idx].file_type->id == GEANY_FILETYPES_JAVA) + { +#ifdef G_OS_WIN32 + // there is already the extension .exe, so first remove it and then add .class + check_executable = utils_remove_ext_from_filename(long_executable); + check_executable = g_strconcat(check_executable, ".class", NULL); +#else check_executable = g_strconcat(long_executable, ".class", NULL); +#endif + } else check_executable = g_strdup(long_executable);
// check whether executable exists if (stat(check_executable, &st) != 0) { +#ifndef G_OS_WIN32 + utf8_check_executable = g_strdup(check_executable); +#else utf8_check_executable = utils_remove_ext_from_filename(doc_list[idx].file_name); msgwin_status_add(_("Failed to execute %s (make sure it is already built)"), utf8_check_executable); +#endif result_id = (GPid) 1; goto free_strings; } @@ -427,10 +456,21 @@ { argv[i] = g_strdup(term_argv[i]); } - argv[term_argv_len ] = g_strdup("-e"); +#ifdef G_OS_WIN32 + // command line arguments for cmd.exe + argv[term_argv_len ] = g_strdup("/Q /C"); + argv[term_argv_len + 1] = g_path_get_basename(script_name); +#else + argv[term_argv_len ] = g_strdup("-e"); argv[term_argv_len + 1] = g_strdup(script_name); +#endif argv[term_argv_len + 2] = NULL;
+ for (i = 0; argv[i] != NULL; i++) + { + msgwin_status_add("%s", argv[i]); + } + if (! g_spawn_async_with_pipes(working_dir, argv, NULL, 0, NULL, NULL, &child_pid, NULL, NULL, NULL, &error)) { @@ -545,37 +585,34 @@ static gboolean build_create_shellscript(const gint idx, const gchar *fname, const gchar *cmd) { FILE *fp; - gint i; - gchar *str, *exec, **tmp_args = NULL, *tmp; + gchar *str; +#ifdef G_OS_WIN32 + gchar *tmp; +#endif
fp = fopen(fname, "w"); if (! fp) return FALSE;
- // enclose all args in "" - tmp_args = g_strsplit(cmd, " ", -1); - for (i = 0; ; i++) - { - if (tmp_args[i] == NULL) break; - tmp = g_strdup(tmp_args[i]); - g_free(tmp_args[i]); - tmp_args[i] = g_strconcat(""", tmp, """, NULL); - g_free(tmp); - } - exec = g_strjoinv(" ", tmp_args); - +#ifdef G_OS_WIN32 + tmp = g_path_get_basename(fname); + str = g_strdup_printf("%s\n\npause\ndel %s\n", cmd, tmp); + g_free(tmp); +#else str = g_strdup_printf( "#!/bin/sh\n\n%s\n\necho "\n\n------------------\n(program exited with code: $?)" \ - \n\necho "Press return to continue"\nread\nunlink $0\n", exec); + \n\necho "Press return to continue"\nread\nunlink $0\n", cmd); +#endif + fputs(str, fp); g_free(str); - g_free(exec); - g_strfreev(tmp_args);
+#ifndef G_OS_WIN32 if (chmod(fname, 0700) != 0) { unlink(fname); return FALSE; } +#endif fclose(fp);
return TRUE;
Modified: trunk/src/callbacks.c =================================================================== --- trunk/src/callbacks.c 2006-09-11 07:41:37 UTC (rev 810) +++ trunk/src/callbacks.c 2006-09-11 11:13:36 UTC (rev 811) @@ -1697,7 +1697,9 @@ document_save_file(idx, FALSE); if (build_run_cmd(idx) == (GPid) 0) { +#ifndef G_OS_WIN32 // on Windows there is no PID returned msgwin_status_add(_("Failed to execute the terminal program")); +#endif } } //gtk_widget_grab_focus(GTK_WIDGET(doc_list[idx].sci));
Modified: trunk/src/main.c =================================================================== --- trunk/src/main.c 2006-09-11 07:41:37 UTC (rev 810) +++ trunk/src/main.c 2006-09-11 11:13:36 UTC (rev 811) @@ -610,10 +610,7 @@
#ifdef G_OS_WIN32 // hide "Build" menu item, at least until it is available for Windows - gtk_widget_hide(lookup_widget(app->window, "menu_build1")); gtk_widget_hide(app->compile_button); - gtk_widget_hide(app->run_button); - gtk_widget_hide(lookup_widget(app->window, "separatortoolitem6")); { GtkWidget *compiler_tab; compiler_tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(msgwindow.notebook),
Modified: trunk/src/prefs.c =================================================================== --- trunk/src/prefs.c 2006-09-11 07:41:37 UTC (rev 810) +++ trunk/src/prefs.c 2006-09-11 11:13:36 UTC (rev 811) @@ -237,18 +237,13 @@ gtk_widget_set_sensitive(lookup_widget(app->prefs_dialog, "label11"), FALSE); gtk_widget_set_sensitive(lookup_widget(app->prefs_dialog, "entry_com_make"), FALSE); gtk_widget_set_sensitive(lookup_widget(app->prefs_dialog, "button_make"), FALSE); - - // hide related Terminal path setting - gtk_widget_set_sensitive(lookup_widget(app->prefs_dialog, "label97"), FALSE); - gtk_widget_set_sensitive(lookup_widget(app->prefs_dialog, "entry_com_term"), FALSE); - gtk_widget_set_sensitive(lookup_widget(app->prefs_dialog, "button_term"), FALSE); #else if (app->tools_make_cmd) gtk_entry_set_text(GTK_ENTRY(lookup_widget(app->prefs_dialog, "entry_com_make")), app->tools_make_cmd); - - if (app->tools_term_cmd) - gtk_entry_set_text(GTK_ENTRY(lookup_widget(app->prefs_dialog, "entry_com_term")), app->tools_term_cmd); #endif + if (app->tools_term_cmd) + gtk_entry_set_text(GTK_ENTRY(lookup_widget(app->prefs_dialog, "entry_com_term")), app->tools_term_cmd); + if (app->tools_browser_cmd) gtk_entry_set_text(GTK_ENTRY(lookup_widget(app->prefs_dialog, "entry_browser")), app->tools_browser_cmd);
@@ -443,11 +438,7 @@ app->pref_toolbar_show_undo = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = lookup_widget(app->prefs_dialog, "check_toolbar_compile"); -#ifdef G_OS_WIN32 - app->pref_toolbar_show_compile = FALSE; -#else app->pref_toolbar_show_compile = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); -#endif
widget = lookup_widget(app->prefs_dialog, "check_toolbar_colour"); app->pref_toolbar_show_colour = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); @@ -912,10 +903,6 @@ app->prefs_dialog = create_prefs_dialog(); gtk_window_set_transient_for(GTK_WINDOW(app->prefs_dialog), GTK_WINDOW(app->window));
-#ifdef G_OS_WIN32 - gtk_widget_hide(lookup_widget(app->prefs_dialog, "check_toolbar_compile")); -#endif - // init the default file encoding combo box combo = lookup_widget(app->prefs_dialog, "combo_encoding"); gtk_combo_box_set_wrap_width(GTK_COMBO_BOX(combo), 3);
Modified: trunk/src/ui_utils.c =================================================================== --- trunk/src/ui_utils.c 2006-09-11 07:41:37 UTC (rev 810) +++ trunk/src/ui_utils.c 2006-09-11 11:13:36 UTC (rev 811) @@ -46,11 +46,10 @@ recent_file_activate_cb (GtkMenuItem *menuitem, gpointer user_data);
-#ifndef G_OS_WIN32 static GtkWidget *create_build_menu_tex(gint idx); static GtkWidget *create_build_menu_gen(gint idx); -#endif
+ /* allow_override is TRUE if text can be ignored when another message has been set * that didn't use allow_override and has not timed out. */ void ui_set_statusbar(const gchar *text, gboolean allow_override) @@ -619,7 +618,6 @@
void ui_build_show_hide(gint idx) { -#ifndef G_OS_WIN32 gboolean is_header = FALSE; gchar *ext = NULL; filetype *ft; @@ -637,12 +635,18 @@
ft = doc_list[idx].file_type;
+#ifdef G_OS_WIN32 + // disable compile and link under Windows until it is implemented + ft->menu_items->can_compile = FALSE; + ft->menu_items->can_link = FALSE; +#endif + if (doc_list[idx].file_name) { ext = strrchr(doc_list[idx].file_name, '.'); }
- // TODO: separate function for matching headers, perhaps based on file extensions + /// TODO: separate function for matching headers, perhaps based on file extensions if (! ext || utils_strcmp(ext + 1, "h") || utils_strcmp(ext + 1, "hpp") || utils_strcmp(ext + 1, "hxx")) { @@ -748,12 +752,9 @@ } } } -#endif }
-#ifndef G_OS_WIN32 - #define GEANY_ADD_WIDGET_ACCEL(gkey, menuitem) \ if (keys[(gkey)]->key != 0) \ gtk_widget_add_accelerator(menuitem, "activate", accel_group, \ @@ -768,6 +769,7 @@
menu = gtk_menu_new();
+#ifndef G_OS_WIN32 if (ft->menu_items->can_compile) { // compile the code @@ -828,13 +830,17 @@ gtk_tooltips_set_tip(tooltips, item, _("Compiles the current file using the " "make tool"), NULL); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_make_activate), GINT_TO_POINTER(2)); +#endif
- if (ft->menu_items->can_exec) - { // execute the code + if (item != NULL) + { item = gtk_separator_menu_item_new(); gtk_widget_show(item); gtk_container_add(GTK_CONTAINER(menu), item); + }
+ if (ft->menu_items->can_exec) + { // execute the code item = gtk_image_menu_item_new_from_stock("gtk-execute", accel_group); gtk_widget_show(item); gtk_container_add(GTK_CONTAINER(menu), item); @@ -878,6 +884,7 @@
menu = gtk_menu_new();
+#ifndef G_OS_WIN32 // DVI item = gtk_image_menu_item_new_with_mnemonic(_("LaTeX -> DVI")); gtk_widget_show(item); @@ -904,28 +911,39 @@ gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), image); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_tex_activate), GINT_TO_POINTER(1));
+ if (item != NULL) + { + item = gtk_separator_menu_item_new(); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item); + } + // build the code with make all - item = gtk_image_menu_item_new_with_mnemonic(_("Build with "make"")); + item = gtk_image_menu_item_new_with_mnemonic(_("_Make all")); gtk_widget_show(item); gtk_container_add(GTK_CONTAINER(menu), item); gtk_tooltips_set_tip(tooltips, item, _("Builds the current file with the " "make tool and the default target"), NULL); - if (keys[GEANY_KEYS_BUILD_MAKE]->key) - gtk_widget_add_accelerator(item, "activate", accel_group, keys[GEANY_KEYS_BUILD_MAKE]->key, - keys[GEANY_KEYS_BUILD_MAKE]->mods, GTK_ACCEL_VISIBLE); + GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_MAKE, item); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_make_activate), GINT_TO_POINTER(0));
// build the code with make - item = gtk_image_menu_item_new_with_mnemonic(_("Build with make (custom target)")); + item = gtk_image_menu_item_new_with_mnemonic(_("Make custom _target")); gtk_widget_show(item); - if (keys[GEANY_KEYS_BUILD_MAKEOWNTARGET]->key) - gtk_widget_add_accelerator(item, "activate", accel_group, keys[GEANY_KEYS_BUILD_MAKEOWNTARGET]->key, - keys[GEANY_KEYS_BUILD_MAKEOWNTARGET]->mods, GTK_ACCEL_VISIBLE); + GEANY_ADD_WIDGET_ACCEL(GEANY_KEYS_BUILD_MAKEOWNTARGET, item); gtk_container_add(GTK_CONTAINER(menu), item); gtk_tooltips_set_tip(tooltips, item, _("Builds the current file with the " "make tool and the specified target"), NULL); g_signal_connect((gpointer) item, "activate", G_CALLBACK(on_build_make_activate), GINT_TO_POINTER(1));
+ if (item != NULL) + { + item = gtk_separator_menu_item_new(); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item); + } +#endif + // DVI view item = gtk_image_menu_item_new_with_mnemonic(_("View DVI file")); gtk_widget_show(item); @@ -976,7 +994,6 @@
return menu; } -#endif
void ui_treeviews_show_hide(gboolean force)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.